[PATCH 1 of 2] revlog: add __contains__ for fast membership test

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Feb 5 06:55:46 CST 2015

On 02/05/2015 12:03 PM, Yuya Nishihara wrote:
> On Wed, 04 Feb 2015 16:21:05 +0000, Pierre-Yves David wrote:
>> On 02/04/2015 01:27 PM, Yuya Nishihara wrote:
>>> +    def __contains__(self, rev):
>>> +        """filtered version of revlog.__contains__"""
>>> +        return (revlog.revlog.__contains__(self, rev)
>>> +                and rev not in self.filteredrevs)
>> I think there is some magical optimisation to do here, like hard coding
>> the __contains__ content and maybe test for the existence of any
>> filtered revision before checking for members
> I thought about it, but I didn't.  There's no hot loop calling __contains__,
> so I can't say it has benefit now.

I think that hardlinking the revlog.__contains__ is simple and a pure 
win. The rest can probably wait for real usecase.

Pierre-Yves David

More information about the Mercurial-devel mailing list