Patchwork revset-only: use `subset &` instead of filtering

login
register
mail settings
Submitter Pierre-Yves David
Date Oct. 17, 2014, 12:37 a.m.
Message ID <6e04ffe6221396653833.1413506242@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/6354/
State Accepted
Headers show

Comments

Pierre-Yves David - Oct. 17, 2014, 12:37 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1412987298 25200
#      Fri Oct 10 17:28:18 2014 -0700
# Node ID 6e04ffe6221396653833e9a2e374c3b2b5b4ca49
# Parent  cd1d993fd93096dbb7886b6cba28b57fff100b3b
revset-only: use `subset &` instead of filtering

The & version is more likely to be optimised.

only(.)
before) wall 0.003216 comb 0.000000 user 0.000000 sys 0.000000 (best of 768)
after)  wall 0.001086 comb 0.000000 user 0.000000 sys 0.000000 (best of 2231)

only(default, stable)
before) wall 0.018469 comb 0.020000 user 0.020000 sys 0.000000 (best of 138)
after)  wall 0.015888 comb 0.010000 user 0.010000 sys 0.000000 (best of 156)
Augie Fackler - Oct. 17, 2014, 2:11 p.m.
On Thu, Oct 16, 2014 at 05:37:22PM -0700, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1412987298 25200
> #      Fri Oct 10 17:28:18 2014 -0700
> # Node ID 6e04ffe6221396653833e9a2e374c3b2b5b4ca49
> # Parent  cd1d993fd93096dbb7886b6cba28b57fff100b3b
> revset-only: use `subset &` instead of filtering

queued thanks

>
> The & version is more likely to be optimised.
>
> only(.)
> before) wall 0.003216 comb 0.000000 user 0.000000 sys 0.000000 (best of 768)
> after)  wall 0.001086 comb 0.000000 user 0.000000 sys 0.000000 (best of 2231)
>
> only(default, stable)
> before) wall 0.018469 comb 0.020000 user 0.020000 sys 0.000000 (best of 138)
> after)  wall 0.015888 comb 0.010000 user 0.010000 sys 0.000000 (best of 156)
>
> diff --git a/mercurial/revset.py b/mercurial/revset.py
> --- a/mercurial/revset.py
> +++ b/mercurial/revset.py
> @@ -406,11 +406,11 @@ def only(repo, subset, x):
>              if not rev in descendants and not rev in include]
>      else:
>          exclude = getset(repo, spanset(repo), args[1])
>
>      results = set(ancestormod.missingancestors(include, exclude, cl.parentrevs))
> -    return filteredset(subset, results.__contains__)
> +    return subset & results
>
>  def bisect(repo, subset, x):
>      """``bisect(string)``
>      Changesets marked in the specified bisect status:
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -406,11 +406,11 @@  def only(repo, subset, x):
             if not rev in descendants and not rev in include]
     else:
         exclude = getset(repo, spanset(repo), args[1])
 
     results = set(ancestormod.missingancestors(include, exclude, cl.parentrevs))
-    return filteredset(subset, results.__contains__)
+    return subset & results
 
 def bisect(repo, subset, x):
     """``bisect(string)``
     Changesets marked in the specified bisect status: