comparison mercurial/filesetlang.py @ 38831:b975c5801487

fileset: reorder 'and' expression to evaluate basic patterns first Timing of a crafted example (when disk cache is warm): $ hg files set:'binary() and path:contrib' (orig) time: real 0.140 secs (user 0.120+0.000 sys 0.020+0.000) (new) time: real 0.040 secs (user 0.030+0.000 sys 0.010+0.000)
author Yuya Nishihara <yuya@tcha.org>
date Sat, 21 Jul 2018 16:41:45 +0900
parents 7e7e2b2ff284
children ca4de8ba5b5f
comparison
equal deleted inserted replaced
38830:bfd5def3fe02 38831:b975c5801487
182 w, t = _optimize(x[2]) 182 w, t = _optimize(x[2])
183 return w, (op, x[1], t) 183 return w, (op, x[1], t)
184 if op == 'not': 184 if op == 'not':
185 w, t = _optimize(x[1]) 185 w, t = _optimize(x[1])
186 return w, (op, t) 186 return w, (op, t)
187 if op in {'and', 'minus'}: 187 if op == 'and':
188 wa, ta = _optimize(x[1])
189 wb, tb = _optimize(x[2])
190 if wa <= wb:
191 return wa, (op, ta, tb)
192 else:
193 return wb, (op, tb, ta)
194 if op == 'minus':
188 wa, ta = _optimize(x[1]) 195 wa, ta = _optimize(x[1])
189 wb, tb = _optimize(x[2]) 196 wb, tb = _optimize(x[2])
190 return max(wa, wb), (op, ta, tb) 197 return max(wa, wb), (op, ta, tb)
191 if op == 'or': 198 if op == 'or':
192 ws, ts = zip(*(_optimize(y) for y in x[1:])) 199 ws, ts = zip(*(_optimize(y) for y in x[1:]))