mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 23:38:50 +03:00
revset: avoid O(n) lookup of invalid revision in rev()
0cc5c10d5dc7 was not the final version of that patch. It was really slow because `l not in repo.changelog` iterates revisions up to `l`. Instead, rev() should utilize spanset.__contains__(). revset #0: rev(210000) 0) wall 0.000039 comb 0.000000 user 0.000000 sys 0.000000 (best of 67978) 1) wall 0.002721 comb 0.000000 user 0.000000 sys 0.000000 (best of 1055) 2) wall 0.000059 comb 0.000000 user 0.000000 sys 0.000000 (best of 45599) (0: 3.2-rc, 1: 0cc5c10d5dc7, 2: this patch) Note that the benchmark result described in 0cc5c10d5dc7 is wrong because it is the one of the initial version.
This commit is contained in:
parent
78b956ae0c
commit
740a18d819
@ -1351,7 +1351,7 @@ def rev(repo, subset, x):
|
||||
except (TypeError, ValueError):
|
||||
# i18n: "rev" is a keyword
|
||||
raise error.ParseError(_("rev expects a number"))
|
||||
if l not in repo.changelog:
|
||||
if l not in fullreposet(repo):
|
||||
return baseset()
|
||||
return subset & baseset([l])
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user