[PATCH 04 of 22] obsstore: minor optimization for the obsolete revset

Martin von Zweigbergk martinvonz at google.com
Tue Jun 6 16:10:38 EDT 2017


On Mon, Jun 5, 2017 at 11:05 PM, Gregory Szorc <gregory.szorc at gmail.com> wrote:
> On Sun, Jun 4, 2017 at 4:59 PM, Jun Wu <quark at fb.com> wrote:
>>
>> # HG changeset patch
>> # User Jun Wu <quark at fb.com>
>> # Date 1496457147 25200
>> #      Fri Jun 02 19:32:27 2017 -0700
>> # Node ID e1d6126ed614db6ec664c79afcb3a141c9a0dfa4
>> # Parent  d492628229c58f8417a8b5925a614e26a16465af
>> # Available At https://bitbucket.org/quark-zju/hg-draft
>> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r
>> e1d6126ed614
>> obsstore: minor optimization for the obsolete revset
>
>
> Queued 4-7.
>
> I wish this one had perf numbers in the commit message. But the patch looks
> correct and avoiding attribute lookups in loops like this is a good
> practice.
>
>>
>>
>> Use local variables in a loop.
>>
>> diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
>> --- a/mercurial/obsolete.py
>> +++ b/mercurial/obsolete.py
>> @@ -1278,10 +1278,8 @@ def clearobscaches(repo):
>>  def _computeobsoleteset(repo):
>>      """the set of obsolete revisions"""
>> -    obs = set()
>>      getnode = repo.changelog.node
>>      notpublic = repo._phasecache.getrevset(repo, (phases.draft,
>> phases.secret))
>> -    for r in notpublic:
>> -        if getnode(r) in repo.obsstore.successors:
>> -            obs.add(r)
>> +    isobs = repo.obsstore.successors.__contains__
>> +    obs = set(r for r in notpublic if isobs(getnode(r)))
>>      return obs

I'll inline "obs" in flight.

>>
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel at mercurial-scm.org
>> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
>
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>


More information about the Mercurial-devel mailing list