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

login
register
mail settings
Submitter Yuya Nishihara
Date March 25, 2015, 2:33 p.m.
Message ID <6118332ed57f6303ee25.1427294034@mimosa>
Download mbox | patch
Permalink /patch/8262/
State Accepted
Commit 7d369fae098efe24ba2d314e92cf4c5fd744de09
Headers show

Comments

Yuya Nishihara - March 25, 2015, 2:33 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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)
Matt Mackall - March 26, 2015, 8:27 p.m.
On Wed, 2015-03-25 at 23:33 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1426493485 -32400
> #      Mon Mar 16 17:11:25 2015 +0900
> # Node ID 6118332ed57f6303ee25c9bead442dae9e65d26b
> # Parent  6aa721d4efffc93720e67342f4d7164b87401ecc
> revset: optimize "x & fullreposet" case

Very nice, queued for default!

Patch

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