Mercurial > hg
comparison mercurial/fileset.py @ 38865:899b4c74209c
fileset: combine union of basic patterns into single matcher
This appears to improve query performance in a big repository than I thought.
Writing less Python in a hot loop, faster computation we gain.
$ hg files --cwd mozilla-central --time 'set:a* + b* + c* + d* + e*'
(orig) time: real 0.670 secs (user 0.640+0.000 sys 0.030+0.000)
(new) time: real 0.210 secs (user 0.180+0.000 sys 0.020+0.000)
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 21 Jul 2018 17:19:12 +0900 |
parents | 61ab546b71c3 |
children | da3bd2afd68d |
comparison
equal
deleted
inserted
replaced
38864:73731fa8d1bd | 38865:899b4c74209c |
---|---|
47 return mctx.matcher([x]) | 47 return mctx.matcher([x]) |
48 | 48 |
49 def kindpatmatch(mctx, x, y): | 49 def kindpatmatch(mctx, x, y): |
50 return stringmatch(mctx, _getkindpat(x, y, matchmod.allpatternkinds, | 50 return stringmatch(mctx, _getkindpat(x, y, matchmod.allpatternkinds, |
51 _("pattern must be a string"))) | 51 _("pattern must be a string"))) |
52 | |
53 def patternsmatch(mctx, *xs): | |
54 allkinds = matchmod.allpatternkinds | |
55 patterns = [getpattern(x, allkinds, _("pattern must be a string")) | |
56 for x in xs] | |
57 return mctx.matcher(patterns) | |
52 | 58 |
53 def andmatch(mctx, x, y): | 59 def andmatch(mctx, x, y): |
54 xm = getmatch(mctx, x) | 60 xm = getmatch(mctx, x) |
55 ym = getmatch(mctx, y) | 61 ym = getmatch(mctx, y) |
56 return matchmod.intersectmatchers(xm, ym) | 62 return matchmod.intersectmatchers(xm, ym) |
434 | 440 |
435 methods = { | 441 methods = { |
436 'string': stringmatch, | 442 'string': stringmatch, |
437 'symbol': stringmatch, | 443 'symbol': stringmatch, |
438 'kindpat': kindpatmatch, | 444 'kindpat': kindpatmatch, |
445 'patterns': patternsmatch, | |
439 'and': andmatch, | 446 'and': andmatch, |
440 'or': ormatch, | 447 'or': ormatch, |
441 'minus': minusmatch, | 448 'minus': minusmatch, |
442 'list': listmatch, | 449 'list': listmatch, |
443 'not': notmatch, | 450 'not': notmatch, |