Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/filesetlang.py @ 38903:73731fa8d1bd
fileset: reorder 'or' expression by weight
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 21 Jul 2018 17:13:34 +0900 |
parents | 61ab546b71c3 |
children | 899b4c74209c |
comparison
equal
deleted
inserted
replaced
38902:61ab546b71c3 | 38903:73731fa8d1bd |
---|---|
205 return wa, _optimizeandops(op, ta, tb) | 205 return wa, _optimizeandops(op, ta, tb) |
206 else: | 206 else: |
207 return wb, _optimizeandops(op, tb, ta) | 207 return wb, _optimizeandops(op, tb, ta) |
208 if op == 'or': | 208 if op == 'or': |
209 ws, ts = zip(*(_optimize(y) for y in x[1:])) | 209 ws, ts = zip(*(_optimize(y) for y in x[1:])) |
210 ts = tuple(it[1] for it in sorted(enumerate(ts), | |
211 key=lambda it: ws[it[0]])) | |
210 return max(ws), (op,) + ts | 212 return max(ws), (op,) + ts |
211 if op == 'list': | 213 if op == 'list': |
212 ws, ts = zip(*(_optimize(y) for y in x[1:])) | 214 ws, ts = zip(*(_optimize(y) for y in x[1:])) |
213 return sum(ws), (op,) + ts | 215 return sum(ws), (op,) + ts |
214 if op == 'func': | 216 if op == 'func': |