Skip to content

Commit

Permalink
Speed up unnecessarily slow and obtuse dict comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
kovidgoyal authored and gsnedders committed Nov 3, 2013
1 parent 1576515 commit 124e975
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions html5lib/html5parser.py
Expand Up @@ -949,17 +949,8 @@ def __init__(self, parser, tree):
self.endTagHandler.default = self.endTagOther

def isMatchingFormattingElement(self, node1, node2):
if node1.name != node2.name or node1.namespace != node2.namespace:
return False
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
return (node1.name == node2.name and node1.namespace ==
node2.namespace and node1.attributes == node2.attributes)

# helper
def addFormattingElement(self, token):
Expand Down

0 comments on commit 124e975

Please sign in to comment.