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

Commit23eb610

Browse files
committed
Change the Genshi treeadapter to avoid O(n^2) string concat.
1 parent90e4348 commit23eb610

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

‎html5lib/treeadapters/genshi.py‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,14 @@
55

66

77
defto_genshi(walker):
8-
text=None
8+
text=[]
99
fortokeninwalker:
1010
type=token["type"]
1111
iftypein ("Characters","SpaceCharacters"):
12-
iftextisNone:
13-
text=token["data"]
14-
else:
15-
text+=token["data"]
16-
eliftextisnotNone:
17-
yieldTEXT,text, (None,-1,-1)
18-
text=None
12+
text.append(token["data"])
13+
eliftext:
14+
yieldTEXT,"".join(text), (None,-1,-1)
15+
text= []
1916

2017
iftypein ("StartTag","EmptyTag"):
2118
iftoken["namespace"]:
@@ -46,5 +43,5 @@ def to_genshi(walker):
4643
else:
4744
pass# FIXME: What to do?
4845

49-
iftextisnotNone:
50-
yieldTEXT,text, (None,-1,-1)
46+
iftext:
47+
yieldTEXT,"".join(text), (None,-1,-1)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp