mirror of
https://github.com/openharmony/third_party_rust_rust-url.git
synced 2026-07-21 01:45:27 -04:00
perf: Split the uts46 table for better cache locality (-4%)
This commit is contained in:
@@ -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
@@ -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
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user