changeset 44316:55b12f2593c1

nodemap: move the iteratio inside the Block object Having the iteration inside the serialization function does not help readability. Now that we have a `Block` object, let us move that code there. Differential Revision: https://phab.mercurial-scm.org/D7843
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 15 Jan 2020 15:48:38 +0100
parents 7762a295fd4d
children 78721bbdb2ab
files mercurial/revlogutils/nodemap.py
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlogutils/nodemap.py	Wed Jan 15 15:48:28 2020 +0100
+++ b/mercurial/revlogutils/nodemap.py	Wed Jan 15 15:48:38 2020 +0100
@@ -221,6 +221,9 @@
 
     contains up to 16 entry indexed from 0 to 15"""
 
+    def __iter__(self):
+        return iter(self.get(i) for i in range(16))
+
 
 def _build_trie(index):
     """build a nodemap trie
@@ -295,7 +298,7 @@
     Children block are assumed to be already persisted 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)