From cf5edc4413e48db354c6d55c4051c11eb7a4e0ae Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 4 Feb 2018 22:19:34 +0100 Subject: [PATCH] doxygen: save some bits. --- doxygen/dox2html5.py | 14 ++++++++++---- doxygen/test/test_search.py | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) 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] || | ($ -- 2.30.2