comparison mercurial/revsetlang.py @ 31800:c63cb2d10d6d

revsetlang: enable optimization of 'x + y' expression It's been disabled since 4d1e56b29a91, but it can be enabled now as the ordering requirement is resolved at analyze().
author Yuya Nishihara <yuya@tcha.org>
date Sat, 14 May 2016 20:51:57 +0900
parents f3b151278655
children 11f501f0a213
comparison
equal deleted inserted replaced
31799:e0dc40530c5a 31800:c63cb2d10d6d
432 ws.append(w) 432 ws.append(w)
433 ts.append(t) 433 ts.append(t)
434 flushss() 434 flushss()
435 if len(ts) == 1: 435 if len(ts) == 1:
436 return ws[0], ts[0] # 'or' operation is fully optimized out 436 return ws[0], ts[0] # 'or' operation is fully optimized out
437 # we can't reorder trees by weight because it would change the order. 437 if order != defineorder:
438 # ("sort(a + b)" == "sort(b + a)", but "a + b" != "b + a") 438 # reorder by weight only when f(a + b) == f(b + a)
439 # ts = tuple(t for w, t in sorted(zip(ws, ts), key=lambda wt: wt[0])) 439 ts = [wt[1] for wt in sorted(zip(ws, ts), key=lambda wt: wt[0])]
440 return max(ws), (op, ('list',) + tuple(ts), order) 440 return max(ws), (op, ('list',) + tuple(ts), order)
441 elif op == 'not': 441 elif op == 'not':
442 # Optimize not public() to _notpublic() because we have a fast version 442 # Optimize not public() to _notpublic() because we have a fast version
443 if x[1][:3] == ('func', ('symbol', 'public'), None): 443 if x[1][:3] == ('func', ('symbol', 'public'), None):
444 order = x[1][3] 444 order = x[1][3]