Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.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 | 1f339b503a40 |
children | d783f945a701 |
comparison
equal
deleted
inserted
replaced
43103:c95b2f40db7c | 43104:74802979dd9d |
---|---|
1761 '''return the tags associated with a node''' | 1761 '''return the tags associated with a node''' |
1762 if not self._tagscache.nodetagscache: | 1762 if not self._tagscache.nodetagscache: |
1763 nodetagscache = {} | 1763 nodetagscache = {} |
1764 for t, n in self._tagscache.tags.iteritems(): | 1764 for t, n in self._tagscache.tags.iteritems(): |
1765 nodetagscache.setdefault(n, []).append(t) | 1765 nodetagscache.setdefault(n, []).append(t) |
1766 for tags in nodetagscache.itervalues(): | 1766 for tags in pycompat.itervalues(nodetagscache): |
1767 tags.sort() | 1767 tags.sort() |
1768 self._tagscache.nodetagscache = nodetagscache | 1768 self._tagscache.nodetagscache = nodetagscache |
1769 return self._tagscache.nodetagscache.get(node, []) | 1769 return self._tagscache.nodetagscache.get(node, []) |
1770 | 1770 |
1771 def nodebookmarks(self, node): | 1771 def nodebookmarks(self, node): |