Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/fileset.py @ 20208:61a47fd64f30 stable
fileset, revset: do not use global parser object for thread safety
parse() cannot be called at the same time because a parser object keeps its
states. This is no problem for command-line hg client, but it would cause
strange errors in multi-threaded hgweb.
Creating parser object is not too expensive.
original:
% python -m timeit -s 'from mercurial import revset' 'revset.parse("0::tip")'
100000 loops, best of 3: 11.3 usec per loop
thread-safe:
% python -m timeit -s 'from mercurial import revset' 'revset.parse("0::tip")'
100000 loops, best of 3: 13.1 usec per loop
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 21 Dec 2013 12:44:19 +0900 |
parents | 19ac0d8ee9a2 |
children | 174d9b8baf5d |
comparison
equal
deleted
inserted
replaced
20168:d4be314b2071 | 20208:61a47fd64f30 |
---|---|
76 else: | 76 else: |
77 raise error.ParseError(_("syntax error"), pos) | 77 raise error.ParseError(_("syntax error"), pos) |
78 pos += 1 | 78 pos += 1 |
79 yield ('end', None, pos) | 79 yield ('end', None, pos) |
80 | 80 |
81 parse = parser.parser(tokenize, elements).parse | 81 def parse(expr): |
82 p = parser.parser(tokenize, elements) | |
83 return p.parse(expr) | |
82 | 84 |
83 def getstring(x, err): | 85 def getstring(x, err): |
84 if x and (x[0] == 'string' or x[0] == 'symbol'): | 86 if x and (x[0] == 'string' or x[0] == 'symbol'): |
85 return x[1] | 87 return x[1] |
86 raise error.ParseError(err) | 88 raise error.ParseError(err) |