chiark / gitweb /
doxygen: save half of node size, as it is aligned to 16bit.
authorVladimír Vondruš <mosra@centrum.cz>
Sat, 20 Jan 2018 22:53:54 +0000 (23:53 +0100)
committerVladimír Vondruš <mosra@centrum.cz>
Tue, 30 Jan 2018 12:16:30 +0000 (13:16 +0100)
Makes it possible to run on the whole Magnum symbol tree.

doxygen/dox2html5.py
doxygen/test/test_search.py

index a585210b7ff07c9617e74005140a0334bdab2694..9294184b961a3b8bcf06e99d209dcb47d2337eb0 100755 (executable)
@@ -52,9 +52,9 @@ import m.math
 import ansilexer
 
 class Trie:
-    #  root  |     |   header       | values |    child    |
-    # offset | ... | size | value # |  ...   | offsets ... |
-    #  32b   |     |  8b  |    8b   | n*16b  |   8b + 24b  |
+    #  root  |     |     header       | values |    child    |
+    # offset | ... | size/2 | value # |  ...   | offsets ... |
+    #  32b   |     |   8b   |    8b   | n*16b  |   8b + 24b  |
     root_offset_struct = struct.Struct('<I')
     header_struct = struct.Struct('<BB')
     value_struct = struct.Struct('<H')
@@ -85,10 +85,9 @@ class Trie:
             child_offsets += [(char, offset)]
 
         # Serialize this node
-        size = 2 + 2*len(self.values) + 4*len(child_offsets)
-
+        size = int(2 + 2*len(self.values) + 4*len(child_offsets))
         serialized = bytearray()
-        serialized += self.header_struct.pack(size, len(self.values))
+        serialized += self.header_struct.pack(int(size/2), len(self.values))
         for v in self.values:
             serialized += self.value_struct.pack(v)
 
index 528e1d659a66f784ced48760f087aa39b9cde79c..cb5c8a932f38a301d3d181ed52da565e2b205dbb 100755 (executable)
@@ -55,9 +55,9 @@ def _pretty_print_trie(serialized: bytearray, hashtable, stats, base_offset, ind
         out += ']'
 
     # print children
-    if base_offset + size - offset > 4: draw_pipe = True
+    if base_offset + size*2 - offset > 4: draw_pipe = True
     child_count = 0
-    while offset < base_offset + size:
+    while offset < base_offset + size*2:
         if child_count or value_count:
             out += '\n'
             out += indent
@@ -91,7 +91,7 @@ max node size:          {} bytes
 max node values:        {}
 max node children:      {}
 max node value index:   {}
-max node child offset:  {}""".lstrip().format(stats.node_count, stats.max_node_size, stats.max_node_values, stats.max_node_children, stats.max_node_value_index, stats.max_node_child_offset)
+max node child offset:  {}""".lstrip().format(stats.node_count, stats.max_node_size*2, stats.max_node_values, stats.max_node_children, stats.max_node_value_index, stats.max_node_child_offset)
     return out, stats
 
 def pretty_print_map(serialized: bytes):
@@ -114,6 +114,7 @@ def pretty_print(serialized: bytes, show_merged=False):
     magic, version, map_offset = search_data_header_struct.unpack_from(serialized)
     assert magic == b'MCS'
     assert version == 0
+    assert not search_data_header_struct.size % 4
 
     pretty_trie, stats = pretty_print_trie(serialized[search_data_header_struct.size:map_offset], show_merged=show_merged)
     pretty_map = pretty_print_map(serialized[map_offset:])