[PATCH 3 of 5] transplant: use set for prune lookup

Mads Kiilerich mads at kiilerich.com
Wed Apr 17 09:12:53 CDT 2013


On 04/17/2013 03:59 PM, Augie Fackler wrote:
> On Tue, Apr 16, 2013 at 07:49:09PM +0200, Mads Kiilerich wrote:
>> # HG changeset patch
>> # User Mads Kiilerich <madski at unity3d.com>
>> # Date 1366133519 -7200
>> #      Tue Apr 16 19:31:59 2013 +0200
>> # Node ID 3f621c427c998d049888ab60e6f40b7258f9f65f
>> # Parent  7b1520771113094fdbe19511ef7ef22f2d2666f2
>> transplant: use set for prune lookup
> Before/after perf numbers? For small sets sometimes the list can be
> better than the set? Does fb care about this, and maybe they have a
> performance dashboard for it?

I haven't done any measurements. I stumbled upon it when looking through 
the code. It seemed like something that obviously used the wrong pattern.

The revrange will only be converted to a set once - that overhead should 
be negligible no matter what. Using a set will change a rebase of n 
changesets while pruning p changesets from O(p+n*p) to O(p+p+n).

/Mads


>
>> diff --git a/hgext/transplant.py b/hgext/transplant.py
>> --- a/hgext/transplant.py
>> +++ b/hgext/transplant.py
>> @@ -633,8 +633,8 @@
>>
>>           tf = tp.transplantfilter(repo, source, p1)
>>           if opts.get('prune'):
>> -            prune = [source.lookup(r)
>> -                     for r in scmutil.revrange(source, opts.get('prune'))]
>> +            prune = set(source.lookup(r)
>> +                        for r in scmutil.revrange(source, opts.get('prune')))
>>               matchfn = lambda x: tf(x) and x not in prune
>>           else:
>>               matchfn = tf
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel at selenic.com
>> http://selenic.com/mailman/listinfo/mercurial-devel



More information about the Mercurial-devel mailing list