Mercurial > hg-stable
diff mercurial/branchmap.py @ 43104:74802979dd9d
py3: define and use pycompat.itervalues()
.itervalues() only exists on Python 2. Python 3's equivalent is
.values(). But we don't want to blindly use .values() everywhere
because on Python 2, it will create a list, which will have performance
implications.
This commit introduces pycompat.itervalues() which will call the appropriate
method on the passed object. We update all callers of obj.itervalues()
to pycompat.itervalues(obj) instead.
With this commit, the only source tranforming remaining is for
iteritems(). Victory is near...
Differential Revision: https://phab.mercurial-scm.org/D7013
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 06 Oct 2019 17:59:15 -0400 |
parents | 687b865b95ad |
children | d783f945a701 |
line wrap: on
line diff
--- a/mercurial/branchmap.py Sun Oct 06 17:45:05 2019 -0400 +++ b/mercurial/branchmap.py Sun Oct 06 17:59:15 2019 -0400 @@ -91,7 +91,7 @@ clbranchinfo = cl.branchinfo rbheads = [] closed = [] - for bheads in remotebranchmap.itervalues(): + for bheads in pycompat.itervalues(remotebranchmap): rbheads += bheads for h in bheads: r = clrev(h) @@ -350,7 +350,7 @@ def iterheads(self): """ returns all the heads """ self._verifyall() - return self._entries.itervalues() + return pycompat.itervalues(self._entries) def copy(self): """return an deep copy of the branchcache object"""