Patchwork revset-_ancestor: use & instead of filter

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

Comments

Pierre-Yves David - Oct. 17, 2014, 12:19 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1412107434 18000
#      Tue Sep 30 15:03:54 2014 -0500
# Node ID cd1d993fd93096dbb7886b6cba28b57fff100b3b
# Parent  840be5ca03e1db16ba994e55597771c418166c97
revset-_ancestor: use & instead of filter

The & operation is more likely optimised.

::10
before) wall 0.028189 comb 0.030000 user 0.030000 sys 0.000000 (best of 100)
after)  wall 0.001050 comb 0.000000 user 0.000000 sys 0.000000 (best of 2326)

::tip
before) wall 0.081132 comb 0.080000 user 0.080000 sys 0.000000 (best of 100)
after)  wall 0.055418 comb 0.050000 user 0.050000 sys 0.000000 (best of 100)
Augie Fackler - Oct. 17, 2014, 2:11 p.m.
On Thu, Oct 16, 2014 at 05:19:02PM -0700, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1412107434 18000
> #      Tue Sep 30 15:03:54 2014 -0500
> # Node ID cd1d993fd93096dbb7886b6cba28b57fff100b3b
> # Parent  840be5ca03e1db16ba994e55597771c418166c97
> revset-_ancestor: use & instead of filter
>

queued, thanks

>
> The & operation is more likely optimised.
>
> ::10
> before) wall 0.028189 comb 0.030000 user 0.030000 sys 0.000000 (best of 100)
> after)  wall 0.001050 comb 0.000000 user 0.000000 sys 0.000000 (best of 2326)
>
> ::tip
> before) wall 0.081132 comb 0.080000 user 0.080000 sys 0.000000 (best of 100)
> after)  wall 0.055418 comb 0.050000 user 0.050000 sys 0.000000 (best of 100)
>
> diff --git a/mercurial/revset.py b/mercurial/revset.py
> --- a/mercurial/revset.py
> +++ b/mercurial/revset.py
> @@ -345,11 +345,11 @@ def ancestor(repo, subset, x):
>  def _ancestors(repo, subset, x, followfirst=False):
>      heads = getset(repo, spanset(repo), x)
>      if not heads:
>          return baseset()
>      s = _revancestors(repo, heads, followfirst)
> -    return subset.filter(s.__contains__)
> +    return subset & s
>
>  def ancestors(repo, subset, x):
>      """``ancestors(set)``
>      Changesets that are ancestors of a changeset in set.
>      """
> _______________________________________________
> 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
@@ -345,11 +345,11 @@  def ancestor(repo, subset, x):
 def _ancestors(repo, subset, x, followfirst=False):
     heads = getset(repo, spanset(repo), x)
     if not heads:
         return baseset()
     s = _revancestors(repo, heads, followfirst)
-    return subset.filter(s.__contains__)
+    return subset & s
 
 def ancestors(repo, subset, x):
     """``ancestors(set)``
     Changesets that are ancestors of a changeset in set.
     """