Speed up unnecessarily slow and obtuse dict comparison

This commit is contained in:
Kovid Goyal 2013-10-26 13:17:09 +05:30
parent 9503652a4b
commit 3e986bccf3

View File

@ -949,17 +949,8 @@ def getPhases(debug):
self.endTagHandler.default = self.endTagOther self.endTagHandler.default = self.endTagOther
def isMatchingFormattingElement(self, node1, node2): def isMatchingFormattingElement(self, node1, node2):
if node1.name != node2.name or node1.namespace != node2.namespace: return (node1.name == node2.name and node1.namespace ==
return False node2.namespace and node1.attributes == node2.attributes)
elif len(node1.attributes) != len(node2.attributes):
return False
else:
attributes1 = sorted(node1.attributes.items())
attributes2 = sorted(node2.attributes.items())
for attr1, attr2 in zip(attributes1, attributes2):
if attr1 != attr2:
return False
return True
# helper # helper
def addFormattingElement(self, token): def addFormattingElement(self, token):