##// END OF EJS Templates
revsetlang: enable optimization of 'x + y' expression...
Yuya Nishihara -
r31800:c63cb2d1 default
parent child Browse files
Show More
@@ -434,9 +434,9 def _optimize(x, small):
434 434 flushss()
435 435 if len(ts) == 1:
436 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.
438 # ("sort(a + b)" == "sort(b + a)", but "a + b" != "b + a")
439 # ts = tuple(t for w, t in sorted(zip(ws, ts), key=lambda wt: wt[0]))
437 if order != defineorder:
438 # reorder by weight only when f(a + b) == f(b + a)
439 ts = [wt[1] for wt in sorted(zip(ws, ts), key=lambda wt: wt[0])]
440 440 return max(ws), (op, ('list',) + tuple(ts), order)
441 441 elif op == 'not':
442 442 # Optimize not public() to _notpublic() because we have a fast version
@@ -1420,19 +1420,19 ordering defined by it.
1420 1420 define)
1421 1421 (or
1422 1422 (list
1423 ('symbol', '2')
1423 1424 (range
1424 1425 ('symbol', '0')
1425 1426 ('symbol', '1')
1426 follow)
1427 ('symbol', '2'))
1427 follow))
1428 1428 follow)
1429 1429 define)
1430 1430 * set:
1431 1431 <filteredset
1432 1432 <spanset- 0:2>,
1433 1433 <addset
1434 <spanset+ 0:1>,
1435 <baseset [2]>>>
1434 <baseset [2]>,
1435 <spanset+ 0:1>>>
1436 1436 2
1437 1437 1
1438 1438 0
@@ -1917,6 +1917,69 ordering defined by it.
1917 1917 1
1918 1918 0
1919 1919
1920 'A + B' can be rewritten to 'B + A' by weight only when the order doesn't
1921 matter (e.g. 'X & (A + B)' can be 'X & (B + A)', but '(A + B) & X' can't):
1922
1923 $ try -p optimized '0:2 & (reverse(contains("a")) + 2)'
1924 * optimized:
1925 (and
1926 (range
1927 ('symbol', '0')
1928 ('symbol', '2')
1929 define)
1930 (or
1931 (list
1932 ('symbol', '2')
1933 (func
1934 ('symbol', 'reverse')
1935 (func
1936 ('symbol', 'contains')
1937 ('string', 'a')
1938 define)
1939 follow))
1940 follow)
1941 define)
1942 * set:
1943 <filteredset
1944 <spanset+ 0:2>,
1945 <addset
1946 <baseset [2]>,
1947 <filteredset
1948 <fullreposet+ 0:9>,
1949 <contains 'a'>>>>
1950 0
1951 1
1952 2
1953
1954 $ try -p optimized '(reverse(contains("a")) + 2) & 0:2'
1955 * optimized:
1956 (and
1957 (range
1958 ('symbol', '0')
1959 ('symbol', '2')
1960 follow)
1961 (or
1962 (list
1963 (func
1964 ('symbol', 'reverse')
1965 (func
1966 ('symbol', 'contains')
1967 ('string', 'a')
1968 define)
1969 define)
1970 ('symbol', '2'))
1971 define)
1972 define)
1973 * set:
1974 <addset
1975 <filteredset
1976 <spanset- 0:2>,
1977 <contains 'a'>>,
1978 <baseset [2]>>
1979 1
1980 0
1981 2
1982
1920 1983 test sort revset
1921 1984 --------------------------------------------
1922 1985
General Comments 0
You need to be logged in to leave comments. Login now