From ee2fa739bbae9da7afc00de73db547fb6cd91151 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Fri, 21 Feb 2025 16:18:36 +0500 Subject: [PATCH] remove_deep2 - fix traversing same element twice (I hope I don't miss anything, no tests seem to fail and performance is increased significantly) but because `subelement_queue` initiated with the `traverse` all `element`'s subelements will be traversed inside `while` loop twice - once as a part of initial queue and another time when `element` is traversed inside the loop and all those elements added to the queue again. Now we just initiate the `queue` with the `element` and it will be traversed inside the loop like any other element. --- src/ifcopenshell-python/ifcopenshell/util/element.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ifcopenshell-python/ifcopenshell/util/element.py b/src/ifcopenshell-python/ifcopenshell/util/element.py index fd86a09158..9034e382be 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/element.py +++ b/src/ifcopenshell-python/ifcopenshell/util/element.py @@ -1489,7 +1489,7 @@ def remove_deep2( subgraph = list(ifc_file.traverse(element, breadth_first=True)) subgraph.extend(also_consider) subgraph_set = set(subgraph) - subelement_queue = ifc_file.traverse(element, max_levels=1) + subelement_queue = [element] while subelement_queue: subelement = subelement_queue.pop(0) if (