From 499c2ed6e7d7ba05d5b5e1c231c6342944cb34e8 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Mon, 16 Mar 2015 17:11:25 +0900 Subject: [PATCH] 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) --- mercurial/revset.py | 2 ++ tests/test-revset.t | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mercurial/revset.py b/mercurial/revset.py index db84687956..b1cca4bbcd 100644 --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -2718,6 +2718,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 index 6dbf1e8641..1434b90f67 100644 --- a/tests/test-revset.t +++ b/tests/test-revset.t @@ -100,8 +100,7 @@ trivial ('symbol', '0') ('symbol', '1')) * set: - > + 0 1 $ try 3::6 @@ -109,8 +108,7 @@ trivial ('symbol', '3') ('symbol', '6')) * set: - > + 3 5 6