Mercurial > public > mercurial-scm > hg
comparison mercurial/revlogutils/nodemap.py @ 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 |
comparison
equal
deleted
inserted
replaced
44315:7762a295fd4d | 44316:55b12f2593c1 |
---|---|
218 | 218 |
219 class Block(dict): | 219 class Block(dict): |
220 """represent a block of the Trie | 220 """represent a block of the Trie |
221 | 221 |
222 contains up to 16 entry indexed from 0 to 15""" | 222 contains up to 16 entry indexed from 0 to 15""" |
223 | |
224 def __iter__(self): | |
225 return iter(self.get(i) for i in range(16)) | |
223 | 226 |
224 | 227 |
225 def _build_trie(index): | 228 def _build_trie(index): |
226 """build a nodemap trie | 229 """build a nodemap trie |
227 | 230 |
293 """produce persistent binary data for a single block | 296 """produce persistent binary data for a single block |
294 | 297 |
295 Children block are assumed to be already persisted and present in | 298 Children block are assumed to be already persisted and present in |
296 block_map. | 299 block_map. |
297 """ | 300 """ |
298 data = tuple(_to_value(block_node.get(i), block_map) for i in range(16)) | 301 data = tuple(_to_value(v, block_map) for v in block_node) |
299 return S_BLOCK.pack(*data) | 302 return S_BLOCK.pack(*data) |
300 | 303 |
301 | 304 |
302 def _to_value(item, block_map): | 305 def _to_value(item, block_map): |
303 """persist any value as an integer""" | 306 """persist any value as an integer""" |