Skip to content

Commit 7b6ec46

Browse files
committed
refactor: remove check that first_code_point is non-ascii
This check was made redundant (it will always be true) when we removed all ASCII characters from the tables (a8c6694).
1 parent 5c9136c commit 7b6ec46

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

src/tools/unicode-table-generator/src/skiplist.rs

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -88,28 +88,21 @@ impl RawEmitter {
8888

8989
// The inlining in this code works like the following:
9090
//
91-
// The `skip_search` function is always inlined into the parent `lookup` fn,
91+
// The `skip_search` function is always inlined into the parent `lookup_slow` fn,
9292
// thus the compiler can generate optimal code based on the referenced `static`s.
9393
//
94-
// In the case of ASCII optimization, the lower-bounds check is inlined into
95-
// the caller, and slower-path `skip_search` is outlined into a separate `lookup_slow` fn.
96-
//
97-
// Thus, in both cases, the `skip_search` function is specialized for the `static`s,
98-
// and outlined into the prebuilt `std`.
99-
if first_code_point > 0x7f {
100-
writeln!(&mut self.file, "#[inline]").unwrap();
101-
writeln!(&mut self.file, "pub fn lookup(c: char) -> bool {{").unwrap();
102-
writeln!(&mut self.file, " debug_assert!(!c.is_ascii());").unwrap();
103-
writeln!(&mut self.file, " (c as u32) >= {first_code_point:#04x} && lookup_slow(c)")
104-
.unwrap();
105-
writeln!(&mut self.file, "}}").unwrap();
106-
writeln!(&mut self.file).unwrap();
107-
writeln!(&mut self.file, "#[inline(never)]").unwrap();
108-
writeln!(&mut self.file, "fn lookup_slow(c: char) -> bool {{").unwrap();
109-
} else {
110-
writeln!(&mut self.file, "pub fn lookup(c: char) -> bool {{").unwrap();
111-
writeln!(&mut self.file, " debug_assert!(!c.is_ascii());").unwrap();
112-
}
94+
// The lower-bounds check is inlined into the caller, and slower-path
95+
// `skip_search` is outlined into a separate `lookup_slow` fn.
96+
assert!(first_code_point > 0x7f);
97+
writeln!(&mut self.file, "#[inline]").unwrap();
98+
writeln!(&mut self.file, "pub fn lookup(c: char) -> bool {{").unwrap();
99+
writeln!(&mut self.file, " debug_assert!(!c.is_ascii());").unwrap();
100+
writeln!(&mut self.file, " (c as u32) >= {first_code_point:#04x} && lookup_slow(c)")
101+
.unwrap();
102+
writeln!(&mut self.file, "}}").unwrap();
103+
writeln!(&mut self.file).unwrap();
104+
writeln!(&mut self.file, "#[inline(never)]").unwrap();
105+
writeln!(&mut self.file, "fn lookup_slow(c: char) -> bool {{").unwrap();
113106
writeln!(&mut self.file, " const {{").unwrap();
114107
writeln!(
115108
&mut self.file,

0 commit comments

Comments
 (0)