# HG changeset patch # User Yuya Nishihara # Date 1426493485 -32400 # Node ID 7d369fae098efe24ba2d314e92cf4c5fd744de09 # Parent 7d87f672d0690761302a4c8530d7719d5e0135dd revset: optimize "x & fullreposet" case If self is a smartset and other is a fullreposet, nothing should be necessary. A small win for trivial query in mozilla-central repo: revset #0: (0:100000) 0) wall 0.017211 comb 0.020000 user 0.020000 sys 0.000000 (best of 163) 1) wall 0.001324 comb 0.000000 user 0.000000 sys 0.000000 (best of 2160) diff -r 7d87f672d069 -r 7d369fae098e mercurial/revset.py --- a/mercurial/revset.py Mon Mar 16 18:36:53 2015 +0900 +++ b/mercurial/revset.py Mon Mar 16 17:11:25 2015 +0900 @@ -2718,6 +2718,8 @@ """Returns a new object with the intersection of the two collections. This is part of the mandatory API for smartset.""" + if isinstance(other, fullreposet): + return self return self.filter(other.__contains__, cache=False) def __add__(self, other): diff -r 7d87f672d069 -r 7d369fae098e tests/test-revset.t --- a/tests/test-revset.t Mon Mar 16 18:36:53 2015 +0900 +++ b/tests/test-revset.t Mon Mar 16 17:11:25 2015 +0900 @@ -100,8 +100,7 @@ ('symbol', '0') ('symbol', '1')) * set: - > + 0 1 $ try 3::6 @@ -109,8 +108,7 @@ ('symbol', '3') ('symbol', '6')) * set: - > + 3 5 6