perf: Split the uts46 table for better cache locality (-4%)

This commit is contained in:
Markus Westerlind
2018-06-20 15:07:38 +02:00
parent 51419c3d00
commit b5f71fd51b
3 changed files with 15247 additions and 7622 deletions
+14 -5
View File
@@ -23,8 +23,6 @@ print('''\
// except according to those terms.
// Generated by make_idna_table.py
static TABLE: &'static [Range] = &[
''')
txt = open("IdnaMappingTable.txt")
@@ -123,12 +121,23 @@ for (k, g) in grouped_ranges:
unicode_str = group[0][3]
optimized_ranges.append((first, last, mapping, unicode_str))
print("static TABLE: &'static [Range] = &[")
for (first, last, mapping, unicode_str) in optimized_ranges:
if unicode_str is not None:
mapping += rust_slice(strtab_slice(unicode_str))
print(" Range { from: '%s', to: '%s', mapping: %s }," % (escape_char(char(first)),
escape_char(char(last)),
mapping))
print(" Range { from: '%s', to: '%s', }," % (escape_char(char(first)),
escape_char(char(last))))
print("];\n")
print("static MAPPING_TABLE: &'static [Mapping] = &[")
for (first, last, mapping, unicode_str) in optimized_ranges:
if unicode_str is not None:
mapping += rust_slice(strtab_slice(unicode_str))
print(" %s," % mapping)
print("];\n")
+1 -2
View File
@@ -55,7 +55,6 @@ enum Mapping {
struct Range {
from: char,
to: char,
mapping: Mapping,
}
fn find_char(codepoint: char) -> &'static Mapping {
@@ -68,7 +67,7 @@ fn find_char(codepoint: char) -> &'static Mapping {
Equal
}
});
r.ok().map(|i| &TABLE[i].mapping).unwrap()
r.ok().map(|i| &MAPPING_TABLE[i]).unwrap()
}
fn map_char(codepoint: char, flags: Flags, output: &mut String, errors: &mut Vec<Error>) {
+15232 -7615
View File
File diff suppressed because it is too large Load Diff