[PATCH] revset: uncache filteredset.__contains__

Augie Fackler raf at durin42.com
Wed Sep 9 10:34:23 CDT 2015


On Thu, Sep 10, 2015 at 12:22:37AM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya at tcha.org>
> # Date 1441425413 -32400
> #      Sat Sep 05 12:56:53 2015 +0900
> # Node ID 1d5f8bda8bb9d4d0e4e4b32eed6253e8b7907073
> # Parent  29d29a82263f4380a73f05160a03887acf18806a
> revset: uncache filteredset.__contains__

queued, thanks

>
> Since 96b6b3d78697, condition function returns a cached value, so there's
> little benefit to cache __contains__.
>
> No measurable difference found in contrib/base-revsets.txt.
>
> diff --git a/mercurial/revset.py b/mercurial/revset.py
> --- a/mercurial/revset.py
> +++ b/mercurial/revset.py
> @@ -3077,14 +3077,9 @@ class filteredset(abstractsmartset):
>          """
>          self._subset = subset
>          self._condition = condition
> -        self._cache = {}
>
>      def __contains__(self, x):
> -        c = self._cache
> -        if x not in c:
> -            v = c[x] = x in self._subset and self._condition(x)
> -            return v
> -        return c[x]
> +        return x in self._subset and self._condition(x)
>
>      def __iter__(self):
>          return self._iterfilter(self._subset)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list