Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit29f0512

Browse files
kovidgoyalgsnedders
authored andcommitted
Speed up unnecessarily slow and obtuse dict comparison
1 parent2812e44 commit29f0512

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

‎html5lib/html5parser.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,17 +1022,9 @@ def __init__(self, parser, tree):
10221022
self.endTagHandler.default=self.endTagOther
10231023

10241024
defisMatchingFormattingElement(self,node1,node2):
1025-
ifnode1.name!=node2.nameornode1.namespace!=node2.namespace:
1026-
returnFalse
1027-
eliflen(node1.attributes)!=len(node2.attributes):
1028-
returnFalse
1029-
else:
1030-
attributes1=sorted(node1.attributes.items())
1031-
attributes2=sorted(node2.attributes.items())
1032-
forattr1,attr2inzip(attributes1,attributes2):
1033-
ifattr1!=attr2:
1034-
returnFalse
1035-
returnTrue
1025+
return (node1.name==node2.nameand
1026+
node1.namespace==node2.namespaceand
1027+
node1.attributes==node2.attributes)
10361028

10371029
# helper
10381030
defaddFormattingElement(self,token):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp