Remove an unnecessary loop

The unprotected_ids function returns all unprotected ids and
removeUnreferencedIDs removes all of them that does not appear in the
return value of findReferencedElements.

On closer observation it turns out that removeUnreferencedIDs cannot
cause nodes/IDs to become unprotected nor unreferenced (as it only
remove the "id" attribute, not the node).  With this in mind, we can
just remove the loop and save a call to all of these functions.

Signed-off-by: Niels Thykier <niels@thykier.net>
This commit is contained in:
Niels Thykier 2018-02-17 17:21:25 +00:00
parent 5360db86d9
commit c0c9a9c2c1

View file

@ -3471,11 +3471,9 @@ def scourString(in_string, options=None):
_num_elements_removed += 1 _num_elements_removed += 1
if options.strip_ids: if options.strip_ids:
bContinueLooping = True referencedIDs = findReferencedElements(doc.documentElement)
while bContinueLooping: identifiedElements = unprotected_ids(doc, options)
identifiedElements = unprotected_ids(doc, options) removeUnreferencedIDs(referencedIDs, identifiedElements)
referencedIDs = findReferencedElements(doc.documentElement)
bContinueLooping = (removeUnreferencedIDs(referencedIDs, identifiedElements) > 0)
while removeDuplicateGradientStops(doc) > 0: while removeDuplicateGradientStops(doc) > 0:
pass pass