[PATCH 3 of 3] revset: optimize "x & fullreposet" case

Yuya Nishihara yuya at tcha.org
Wed Mar 25 09:33:54 CDT 2015


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1426493485 -32400
#      Mon Mar 16 17:11:25 2015 +0900
# Node ID 6118332ed57f6303ee25c9bead442dae9e65d26b
# Parent  6aa721d4efffc93720e67342f4d7164b87401ecc
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 --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -2674,6 +2674,8 @@ class abstractsmartset(object):
         """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 --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -100,8 +100,7 @@ trivial
     ('symbol', '0')
     ('symbol', '1'))
   * set:
-  <filteredset
-    <spanset+ 0:1>>
+  <spanset+ 0:1>
   0
   1
   $ try 3::6
@@ -109,8 +108,7 @@ trivial
     ('symbol', '3')
     ('symbol', '6'))
   * set:
-  <filteredset
-    <baseset [3, 5, 6]>>
+  <baseset [3, 5, 6]>
   3
   5
   6


More information about the Mercurial-devel mailing list