From 7fe722ff68bb9b971f62a3f5805c910243a1e7d8 Mon Sep 17 00:00:00 2001 From: Shallowmallow Date: Thu, 29 Aug 2024 10:36:55 +0200 Subject: [PATCH 1/2] Try to remove only direct item renderer children --- haxe/ui/containers/Box.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haxe/ui/containers/Box.hx b/haxe/ui/containers/Box.hx index b2c3de8bf..b8deca56e 100644 --- a/haxe/ui/containers/Box.hx +++ b/haxe/ui/containers/Box.hx @@ -155,7 +155,7 @@ private class Builder extends CompositeBuilder { renderer.data = item; } - for (child in _component.findComponents(ItemRenderer)) { + for (child in _component.findComponents(ItemRenderer, 1)) { if (child == _box.itemRenderer) { continue; } From ffe5e78101be4a241dcd3444c644596d5fed511e Mon Sep 17 00:00:00 2001 From: Shallowmallow Date: Thu, 29 Aug 2024 11:30:23 +0200 Subject: [PATCH 2/2] Limiting the use findRenderers, using it once instead number of items in dataSource --- haxe/ui/containers/Box.hx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/haxe/ui/containers/Box.hx b/haxe/ui/containers/Box.hx index b8deca56e..7191988a8 100644 --- a/haxe/ui/containers/Box.hx +++ b/haxe/ui/containers/Box.hx @@ -143,9 +143,11 @@ private class Builder extends CompositeBuilder { _box.itemRenderer.handleVisibility(false); } + var childRenderers = _component.findComponents(ItemRenderer, 1); + for (i in 0...dataSource.size) { var item = dataSource.get(i); - var renderer = findRenderer(item); + var renderer = findRenderer(item, childRenderers); if (renderer == null) { renderer = itemRenderer.cloneComponent(); _box.addComponent(renderer); @@ -155,7 +157,7 @@ private class Builder extends CompositeBuilder { renderer.data = item; } - for (child in _component.findComponents(ItemRenderer, 1)) { + for (child in childRenderers) { if (child == _box.itemRenderer) { continue; } @@ -165,8 +167,8 @@ private class Builder extends CompositeBuilder { } } - private function findRenderer(data:Dynamic):ItemRenderer { - for (child in _component.findComponents(ItemRenderer)) { + private function findRenderer(data:Dynamic, renderers:Array):ItemRenderer { + for (child in renderers) { if (child.data == data) { return child; }