From: Vladimír Vondruš Date: Sun, 4 Feb 2018 21:19:34 +0000 (+0100) Subject: doxygen: save some bits. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?a=commitdiff_plain;h=cf5edc4413e48db354c6d55c4051c11eb7a4e0ae;p=blog.git doxygen: save some bits. --- diff --git a/doxygen/dox2html5.py b/doxygen/dox2html5.py index 92430de2..32fee0c9 100755 --- a/doxygen/dox2html5.py +++ b/doxygen/dox2html5.py @@ -288,8 +288,13 @@ class ResultMap: if e.flags & ResultFlag.HAS_SUFFIX: offset += 1 - # Length of name, URL and 0-delimiter - offset += len(e.name.encode('utf-8')) + len(e.url.encode('utf-8')) + 1 + # Length of the name + offset += len(e.name.encode('utf-8')) + + # Length of the URL and 0-delimiter. If URL is empty, it's not + # added at all, then the 0-delimiter is also not needed. + if e.name and e.url: + offset += len(e.url.encode('utf-8')) + 1 # Write file size output += self.offset_struct.pack(offset) @@ -302,8 +307,9 @@ class ResultMap: if e.flags & ResultFlag.HAS_SUFFIX: output += self.suffix_length_struct.pack(e.suffix_length) output += e.name.encode('utf-8') - output += b'\0' - output += e.url.encode('utf-8') + if e.url: + output += b'\0' + output += e.url.encode('utf-8') assert len(output) == offset return output diff --git a/doxygen/test/test_search.py b/doxygen/test/test_search.py index 33428f5a..f2837596 100755 --- a/doxygen/test/test_search.py +++ b/doxygen/test/test_search.py @@ -367,7 +367,7 @@ class Search(IntegrationTestCase): serialized = f.read() search_data_pretty = pretty_print(serialized)[0] #print(search_data_pretty) - self.assertEqual(len(serialized), 3712) + self.assertEqual(len(serialized), 3704) self.assertEqual(search_data_pretty, """ deprecated_macro [0] || | ($