Patchwork D7842: nodemap: use an explicit "Block" object in the reference implementation

login
register
mail settings
Submitter phabricator
Date Jan. 31, 2020, 3:29 p.m.
Message ID <7a9c3f7546d947135f1abe833c0b06c9@localhost.localdomain>
Download mbox | patch
Permalink /patch/44805/
State Not Applicable
Headers show

Comments

phabricator - Jan. 31, 2020, 3:29 p.m.
marmoute updated this revision to Diff 19758.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7842?vs=19296&id=19758

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7842/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7842

AFFECTED FILES
  mercurial/revlogutils/nodemap.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/revlogutils/nodemap.py b/mercurial/revlogutils/nodemap.py
--- a/mercurial/revlogutils/nodemap.py
+++ b/mercurial/revlogutils/nodemap.py
@@ -215,6 +215,14 @@ 
     return int(hex_digit, 16)
 
 
+class Block(dict):
+    """represent a block of the Trie
+
+    contains up to 16 entry indexed from 0 to 15"""
+
+    pass
+
+
 def _build_trie(index):
     """build a nodemap trie
 
@@ -223,7 +231,7 @@ 
     Each block is a dictionary with keys in `[0, 15]`. Values are either
     another block or a revision number.
     """
-    root = {}
+    root = Block()
     for rev in range(len(index)):
         hex = nodemod.hex(index[rev][7])
         _insert_into_block(index, 0, root, rev, hex)
@@ -251,7 +259,7 @@ 
         # vertices to fit both entry.
         other_hex = nodemod.hex(index[entry][7])
         other_rev = entry
-        new = {}
+        new = Block()
         block[_to_int(current_hex[level])] = new
         _insert_into_block(index, level + 1, new, other_rev, other_hex)
         _insert_into_block(index, level + 1, new, current_rev, current_hex)