Show More
@@ -216,6 +216,12 b' def _to_int(hex_digit):' | |||||
216 | return int(hex_digit, 16) |
|
216 | return int(hex_digit, 16) | |
217 |
|
217 | |||
218 |
|
218 | |||
|
219 | class Block(dict): | |||
|
220 | """represent a block of the Trie | |||
|
221 | ||||
|
222 | contains up to 16 entry indexed from 0 to 15""" | |||
|
223 | ||||
|
224 | ||||
219 | def _build_trie(index): |
|
225 | def _build_trie(index): | |
220 | """build a nodemap trie |
|
226 | """build a nodemap trie | |
221 |
|
227 | |||
@@ -224,7 +230,7 b' def _build_trie(index):' | |||||
224 | Each block is a dictionary with keys in `[0, 15]`. Values are either |
|
230 | Each block is a dictionary with keys in `[0, 15]`. Values are either | |
225 | another block or a revision number. |
|
231 | another block or a revision number. | |
226 | """ |
|
232 | """ | |
227 |
root = |
|
233 | root = Block() | |
228 | for rev in range(len(index)): |
|
234 | for rev in range(len(index)): | |
229 | hex = nodemod.hex(index[rev][7]) |
|
235 | hex = nodemod.hex(index[rev][7]) | |
230 | _insert_into_block(index, 0, root, rev, hex) |
|
236 | _insert_into_block(index, 0, root, rev, hex) | |
@@ -253,7 +259,7 b' def _insert_into_block(index, level, blo' | |||||
253 | # vertices to fit both entry. |
|
259 | # vertices to fit both entry. | |
254 | other_hex = nodemod.hex(index[entry][7]) |
|
260 | other_hex = nodemod.hex(index[entry][7]) | |
255 | other_rev = entry |
|
261 | other_rev = entry | |
256 |
new = |
|
262 | new = Block() | |
257 | block[hex_digit] = new |
|
263 | block[hex_digit] = new | |
258 | _insert_into_block(index, level + 1, new, other_rev, other_hex) |
|
264 | _insert_into_block(index, level + 1, new, other_rev, other_hex) | |
259 | _insert_into_block(index, level + 1, new, current_rev, current_hex) |
|
265 | _insert_into_block(index, level + 1, new, current_rev, current_hex) |
General Comments 0
You need to be logged in to leave comments.
Login now