nodemap: move the iteratio inside the Block object
authorPierre-Yves David <pierre-yves.david@octobus.net>
Wed, 15 Jan 2020 15:48:38 +0100
changeset 44359 55b12f2593c1
parent 44358 7762a295fd4d
child 44360 78721bbdb2ab
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
mercurial/revlogutils/nodemap.py
--- 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)