Mercurial > hg-stable
changeset 27327:d500341e4f55
match: use re2 in readpatternfile if possible
This has a small, but measurable, effect on performance if a pattern
file is very large. In an artificial test with 200,000 lines of
pattern data, using re2 reduced read time by 200 milliseconds.
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Thu, 10 Dec 2015 21:33:55 -0800 |
parents | ee2d7b5daa8a |
children | 96dc6664fa9c |
files | mercurial/match.py |
diffstat | 1 files changed, 4 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/match.py Thu Dec 10 21:32:19 2015 -0800 +++ b/mercurial/match.py Thu Dec 10 21:33:55 2015 -0800 @@ -654,9 +654,11 @@ if "#" in line: global _commentre if not _commentre: - _commentre = re.compile(r'((^|[^\\])(\\\\)*)#.*') + _commentre = util.re.compile(r'((?:^|[^\\])(?:\\\\)*)#.*') # remove comments prefixed by an even number of escapes - line = _commentre.sub(r'\1', line) + m = _commentre.search(line) + if m: + line = line[:m.end(1)] # fixup properly escaped comments that survived the above line = line.replace("\\#", "#") line = line.rstrip()