summaryrefslogtreecommitdiff
path: root/src/lxml/_elementpath.py
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2017-10-01 14:32:50 +0200
committerStefan Behnel <stefan_ml@behnel.de>2017-10-01 14:32:50 +0200
commitcb59c0c86729a3ac0136ed4d2c39eaa14c64c5b2 (patch)
tree561d7d86896cf67fc49f6e2f27365363dd2b5733 /src/lxml/_elementpath.py
parent7c5a14a08e68b1490e9fde3405abd125cf63cd13 (diff)
downloadpython-lxml-cb59c0c86729a3ac0136ed4d2c39eaa14c64c5b2.tar.gz
Avoid string list+join overhead in ElementPath parser since predicate signatures are very short.
Diffstat (limited to 'src/lxml/_elementpath.py')
-rw-r--r--src/lxml/_elementpath.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lxml/_elementpath.py b/src/lxml/_elementpath.py
index 4761e481..e4015ffb 100644
--- a/src/lxml/_elementpath.py
+++ b/src/lxml/_elementpath.py
@@ -134,7 +134,7 @@ def prepare_predicate(next, token):
# FIXME: replace with real parser!!! refs:
# http://effbot.org/zone/simple-iterator-parser.htm
# http://javascript.crockford.com/tdop/tdop.html
- signature = []
+ signature = ''
predicate = []
while 1:
token = next()
@@ -144,9 +144,9 @@ def prepare_predicate(next, token):
continue
if token[0] and token[0][:1] in "'\"":
token = "'", token[0][1:-1]
- signature.append(token[0] or "-")
+ signature += token[0] or "-"
predicate.append(token[1])
- signature = "".join(signature)
+
# use signature to determine predicate type
if signature == "@-":
# [@attribute] predicate