fix/263 performance regression (#264)

* Replace deep copies in Component.render
* Add 2nd example component to sampleproject
This commit is contained in:
adriaan 2023-04-13 14:20:43 +02:00 committed by GitHub
parent 2cfc7285e1
commit 6f49339c91
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 7 deletions

View file

@ -1,4 +1,3 @@
import copy
from typing import (
TYPE_CHECKING,
ClassVar,
@ -126,12 +125,13 @@ class Component(metaclass=SimplifiedInterfaceMediaDefiningClass):
return self._outer_context or {}
def get_updated_fill_stacks(self, context):
current_fill_stacks = context.get(FILLED_SLOTS_CONTEXT_KEY, None)
updated_fill_stacks = (
copy.deepcopy(current_fill_stacks)
if current_fill_stacks is not None
else {}
current_fill_stacks: Optional[Dict[str, List[FillNode]]] = context.get(
FILLED_SLOTS_CONTEXT_KEY, None
)
updated_fill_stacks = {}
if current_fill_stacks:
for name, fill_nodes in current_fill_stacks.items():
updated_fill_stacks[name] = list(fill_nodes)
for name, fill in self.instance_fills.items():
if name in updated_fill_stacks:
updated_fill_stacks[name].append(fill)