diff options
| author | Stefan Behnel <stefan_ml@behnel.de> | 2017-10-01 14:32:50 +0200 |
|---|---|---|
| committer | Stefan Behnel <stefan_ml@behnel.de> | 2017-10-01 14:32:50 +0200 |
| commit | cb59c0c86729a3ac0136ed4d2c39eaa14c64c5b2 (patch) | |
| tree | 561d7d86896cf67fc49f6e2f27365363dd2b5733 /src/lxml/_elementpath.py | |
| parent | 7c5a14a08e68b1490e9fde3405abd125cf63cd13 (diff) | |
| download | python-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.py | 6 |
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 |
