Make the generated public suffix list constexpr

Signed-off-by: Yuhang Zhao <2546789017@qq.com>
This commit is contained in:
Yuhang Zhao 2022-05-30 09:10:56 +08:00
parent 664f3dc852
commit fda3a213f3
1 changed files with 5 additions and 5 deletions

View File

@ -161,7 +161,7 @@ sink = None
A C++ representation of the compressed graph is generated: A C++ representation of the compressed graph is generated:
const unsigned char dafsa[7] = { constexpr unsigned char dafsa[7] = {
0x81, 0xE1, 0x02, 0x81, 0x82, 0x61, 0x81, 0x81, 0xE1, 0x02, 0x81, 0x82, 0x61, 0x81,
}; };
@ -198,7 +198,7 @@ sink = None
A C++ representation of the compressed graph is generated: A C++ representation of the compressed graph is generated:
const unsigned char dafsa[11] = { constexpr unsigned char dafsa[11] = {
0x02, 0x83, 0xE2, 0x02, 0x83, 0x61, 0x61, 0x81, 0x62, 0x62, 0x82, 0x02, 0x83, 0xE2, 0x02, 0x83, 0x61, 0x61, 0x81, 0x62, 0x62, 0x82,
}; };
@ -490,7 +490,7 @@ def to_cxx(data, codecs):
text += b'The byte array encodes effective tld names. See psl-make-dafsa source for' text += b'The byte array encodes effective tld names. See psl-make-dafsa source for'
text += b' documentation.' text += b' documentation.'
text += b'*/\n\n' text += b'*/\n\n'
text += b'static const unsigned char kDafsa[' text += b'static constexpr unsigned char kDafsa['
text += bytes(str(len(data)), **codecs) text += bytes(str(len(data)), **codecs)
text += b'] = {\n' text += b'] = {\n'
for i in range(0, len(data), 12): for i in range(0, len(data), 12):
@ -517,8 +517,8 @@ def to_cxx_plus(data, codecs):
text += b'static int _psl_nsuffixes = %d;\n' % psl_nsuffixes text += b'static int _psl_nsuffixes = %d;\n' % psl_nsuffixes
text += b'static int _psl_nexceptions = %d;\n' % psl_nexceptions text += b'static int _psl_nexceptions = %d;\n' % psl_nexceptions
text += b'static int _psl_nwildcards = %d;\n' % psl_nwildcards text += b'static int _psl_nwildcards = %d;\n' % psl_nwildcards
text += b'static const char _psl_sha1_checksum[] = "%s";\n' % bytes(sha1_file(psl_input_file), **codecs) text += b'static constexpr char _psl_sha1_checksum[] = "%s";\n' % bytes(sha1_file(psl_input_file), **codecs)
text += b'static const char _psl_filename[] = "%s";\n' % bytes(psl_input_file, **codecs) text += b'static constexpr char _psl_filename[] = "%s";\n' % bytes(psl_input_file, **codecs)
return text return text
def words_to_whatever(words, converter, utf_mode, codecs): def words_to_whatever(words, converter, utf_mode, codecs):