From patchwork Mon Jan 13 15:09:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D7843: nodemap: move the iteratio inside the Block object From: phabricator X-Patchwork-Id: 44284 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Mon, 13 Jan 2020 15:09:14 +0000 marmoute created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY Having the iteration inside the serialization function does not help readability. Now that we have a `Block` object, let us move that code there. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D7843 AFFECTED FILES mercurial/revlogutils/nodemap.py CHANGE DETAILS To: marmoute, #hg-reviewers Cc: mercurial-devel diff --git a/mercurial/revlogutils/nodemap.py b/mercurial/revlogutils/nodemap.py --- a/mercurial/revlogutils/nodemap.py +++ b/mercurial/revlogutils/nodemap.py @@ -219,7 +219,8 @@ contains up to 16 entry indexed from 0 to 15""" - pass + def __iter__(self): + return iter(self.get(i) for i in range(16)) def _build_trie(index): @@ -297,7 +298,7 @@ Children block are assumed to be already serialized and present in block_map. """ - data = tuple(_to_value(block_node.get(i), block_map) for i in range(16)) + data = tuple(_to_value(v, block_map) for v in block_node) return S_BLOCK.pack(*data)