remove_representation - optimization

In some cases remove_representation got 2x times faster (when there were a lot representation items that are not IfcTessellatedFaceSets).

getattr with attribute that might not be present on the element could be much slower then checking it's class explicitly.
This commit is contained in:
Andrej730
2025-06-13 16:43:53 +05:00
parent 176c5cc0fb
commit 67b539aba1
@@ -51,8 +51,9 @@ def remove_representation(
for s in subelement.LayerAssignment if not is_ifc2x3 else subelement.LayerAssignments:
presentation_layer_assignments_items.add(s)
# IfcTessellatedFaceSet inverses
[textures.add(t) for t in getattr(subelement, "HasTextures", []) or []]
[colours.add(t) for t in getattr(subelement, "HasColours", []) or []]
if subelement.is_a() == "IfcTessellatedFaceSet":
textures.update(subelement.HasTextures)
colours.update(subelement.HasColours)
elif subelement.is_a("IfcRepresentation"):
for layer in subelement.LayerAssignments:
presentation_layer_assignments_reps.add(layer)