Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revset.py @ 25344:ceaf04bb14ff
revset: add fast path for _list() of integer revisions
This can greatly speed up chained 'or' of integer revisions.
1) reduce nesting of chained 'or' operations
2) optimize to a list
3) fast path for integer revisions (this patch)
revset #0: 0 + 1 + 2 + ... + 1000
1) wall 0.483341 comb 0.480000 user 0.480000 sys 0.000000 (best of 20)
2) wall 0.025393 comb 0.020000 user 0.020000 sys 0.000000 (best of 107)
3) wall 0.008371 comb 0.000000 user 0.000000 sys 0.000000 (best of 317)
revset #1: sort(0 + 1 + 2 + ... + 1000)
1) wall 0.035240 comb 0.040000 user 0.040000 sys 0.000000 (best of 100)
2) wall 0.026432 comb 0.030000 user 0.030000 sys 0.000000 (best of 102)
3) wall 0.008418 comb 0.000000 user 0.000000 sys 0.000000 (best of 322)
revset #2: first(0 + 1 + 2 + ... + 1000)
1) wall 0.028949 comb 0.030000 user 0.030000 sys 0.000000 (best of 100)
2) wall 0.025503 comb 0.030000 user 0.030000 sys 0.000000 (best of 106)
3) wall 0.008423 comb 0.010000 user 0.010000 sys 0.000000 (best of 319)
But I admit that it is still slower than the spanset.
revset #3: 0:1000
3) wall 0.000132 comb 0.000000 user 0.000000 sys 0.000000 (best of 19010)
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 17 May 2015 15:16:13 +0900 |
parents | 7fbef7932af9 |
children | 99a1f73af85b |
comparison
equal
deleted
inserted
replaced
25343:7fbef7932af9 | 25344:ceaf04bb14ff |
---|---|
1920 s = getstring(x, "internal error") | 1920 s = getstring(x, "internal error") |
1921 if not s: | 1921 if not s: |
1922 return baseset() | 1922 return baseset() |
1923 # remove duplicates here. it's difficult for caller to deduplicate sets | 1923 # remove duplicates here. it's difficult for caller to deduplicate sets |
1924 # because different symbols can point to the same rev. | 1924 # because different symbols can point to the same rev. |
1925 cl = repo.changelog | |
1925 ls = [] | 1926 ls = [] |
1926 seen = set() | 1927 seen = set() |
1927 for t in s.split('\0'): | 1928 for t in s.split('\0'): |
1928 r = repo[t].rev() | 1929 try: |
1930 # fast path for integer revision | |
1931 r = int(t) | |
1932 if str(r) != t or r not in cl: | |
1933 raise ValueError | |
1934 except ValueError: | |
1935 r = repo[t].rev() | |
1929 if r in seen: | 1936 if r in seen: |
1930 continue | 1937 continue |
1931 if (r in subset | 1938 if (r in subset |
1932 or r == node.nullrev and isinstance(subset, fullreposet)): | 1939 or r == node.nullrev and isinstance(subset, fullreposet)): |
1933 ls.append(r) | 1940 ls.append(r) |