[PATCH] revset: cache smartset's min/max

Augie Fackler raf at durin42.com
Fri Aug 28 12:31:54 CDT 2015


On Thu, Aug 27, 2015 at 06:12:52PM -0700, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at fb.com>
> # Date 1440723453 25200
> #      Thu Aug 27 17:57:33 2015 -0700
> # Node ID b0fb67f6080b742e1a45cccc68668bac0b5498c6
> # Parent  cf3212174adb57b7699a77e20295e9c8d36d9aa2
> revset: cache smartset's min/max

Queued, thanks.

>
> As the content of a smartset never changes, min and max will never change
> either.  This will save use time when this function is called multiple time.
> This is relevant for issue4782 but does not fix it.
>
> diff --git a/mercurial/revset.py b/mercurial/revset.py
> --- a/mercurial/revset.py
> +++ b/mercurial/revset.py
> @@ -2884,18 +2884,20 @@ class abstractsmartset(object):
>
>      def isdescending(self):
>          """True if the set will iterate in descending order"""
>          raise NotImplementedError()
>
> +    @util.cachefunc
>      def min(self):
>          """return the minimum element in the set"""
>          if self.fastasc is not None:
>              for r in self.fastasc():
>                  return r
>              raise ValueError('arg is an empty sequence')
>          return min(self)
>
> +    @util.cachefunc
>      def max(self):
>          """return the maximum element in the set"""
>          if self.fastdesc is not None:
>              for r in self.fastdesc():
>                  return r
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list