Commits

Geoffrey Sneddon  committed 05aa19d

Make to_remove a set everywhere.

  • Participants
  • Parent commits 3525088
  • Tags 1.0a1

Comments (0)

Files changed (2)

File specGen/processes/toc.py

 		# Numbering
 		num = []
 		
-		# List of elements to remove (due to odd behaviour of Element.iter() this has to be done afterwards)
-		to_remove = []
+		# Set of elements to remove (due to odd behaviour of Element.iter() this has to be done afterwards)
+		to_remove = set()
 		
 		# Loop over all sections in a DFS
 		while sections:
 										else:
 											element.getparent().text += element.tail
 								# Add the element of the list of elements to remove
-								to_remove.append(element)
+								to_remove.add(element)
 						# Remove unwanted attributes
 						for element in link.iter(tag=etree.Element):
 							for attribute_name in remove_attributes_from_toc:
 			element.getparent().remove(element)
 	
 	def addToc(self, ElementTree, **kwargs):
-		to_remove = []
+		to_remove = set()
 		in_toc = False
 		for node in ElementTree.iter():
 			if in_toc:
 						raise DifferentParentException
 					in_toc = False
 				else:
-					to_remove.append(node)
+					to_remove.add(node)
 			elif node.tag is etree.Comment:
 				if node.text.strip(utils.spaceCharacters) == "begin-toc":
 					toc_parent = node.getparent()
 					node.addprevious(etree.Comment("begin-toc"))
 					node.addprevious(deepcopy(self.toc))
 					node.addprevious(etree.Comment("end-toc"))
-					to_remove.append(node)
+					to_remove.add(node)
 		for node in to_remove:
 			node.getparent().remove(node)
 

File specGen/processes/xref.py

 				self.dfns[term] = id
 	
 	def addReferences(self, ElementTree, w3c_compat = False, w3c_compat_xref_elements = False, w3c_compat_xref_a_placement = False, **kwargs):
-		to_remove = []
+		to_remove = set()
 		for element in ElementTree.iter(tag=etree.Element):
 			if element.tag in term_elements or (w3c_compat or w3c_compat_xref_elements) and element.tag in w3c_term_elements:
 				term = self.getTerm(element, w3c_compat=w3c_compat, **kwargs)
 								link.tail = link[0].tail
 								link[0].tail = None
 								element.addprevious(link)
-								to_remove.append(element)
+								to_remove.add(element)
 		for element in to_remove:
 			element.getparent().remove(element)