cleanup document: list -> set (#2819)

pull/2853/head dev-build-kaalleen-font-info-int
Kaalleen 2024-04-06 08:26:48 +02:00 zatwierdzone przez GitHub
rodzic 36ab53301d
commit 25984cf01d
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
1 zmienionych plików z 6 dodań i 6 usunięć

Wyświetl plik

@ -32,24 +32,24 @@ class Cleanup(InkstitchExtension):
self.svg.selection.clear() self.svg.selection.clear()
self.get_elements() self.get_elements()
self.elements_to_remove = [] self.elements_to_remove = set()
svg = self.document.getroot() svg = self.document.getroot()
empty_d_objects = svg.xpath(".//svg:path[@d='' or not(@d)]", namespaces=NSS) empty_d_objects = svg.xpath(".//svg:path[@d='' or not(@d)]", namespaces=NSS)
for empty in empty_d_objects: for empty in empty_d_objects:
self.elements_to_remove.append(empty) self.elements_to_remove.add(empty)
for element in self.elements: for element in self.elements:
if self.rm_fill and (isinstance(element, FillStitch) and element.shape.area < self.fill_threshold): if self.rm_fill and (isinstance(element, FillStitch) and element.shape.area < self.fill_threshold):
self.elements_to_remove.append(element.node) self.elements_to_remove.add(element.node)
if self.rm_stroke and (isinstance(element, Stroke) and if self.rm_stroke and (isinstance(element, Stroke) and
element.shape.length < self.stroke_threshold and element.node.getparent() is not None): element.shape.length < self.stroke_threshold and element.node.getparent() is not None):
self.elements_to_remove.append(element.node) self.elements_to_remove.add(element.node)
self.groups_to_remove = [] self.groups_to_remove = set()
if self.rm_groups: if self.rm_groups:
for group in self.svg.iterdescendants(SVG_GROUP_TAG): for group in self.svg.iterdescendants(SVG_GROUP_TAG):
if len(group.getchildren()) == 0: if len(group.getchildren()) == 0:
self.groups_to_remove.append(group) self.groups_to_remove.add(group)
if self.dry_run: if self.dry_run:
self._dry_run() self._dry_run()