Skip to content

Selected patches from Calibre #245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 22, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Speed up unnecessarily slow and obtuse dict comparison
  • Loading branch information
kovidgoyal authored and gsnedders committed May 22, 2016
commit 29f0512e4cf4a4fb63b5e7c90ca3e53150a59743
14 changes: 3 additions & 11 deletions html5lib/html5parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1022,17 +1022,9 @@ 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