Skip to content

Commit 63fa0f2

Browse files
committed
Include 2-character ranges in array-based state transitions
1 parent 056237f commit 63fa0f2

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

cli/src/generate/render.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -710,28 +710,35 @@ impl Generator {
710710
// pairs, instead of individual if statements, in order to reduce compile
711711
// time.
712712
let mut leading_simple_transition_count = 0;
713-
let mut leading_simple_transition_character_count = 0;
713+
let mut leading_simple_transition_range_count = 0;
714714
for (chars, action) in &state.advance_actions {
715715
if action.in_main_token
716-
&& chars
717-
.ranges()
718-
.all(|r| r.start() == r.end() && *r.start() as u32 <= u16::MAX as u32)
716+
&& chars.ranges().all(|r| {
717+
let start = *r.start() as u32;
718+
let end = *r.end() as u32;
719+
end <= start + 1 && end <= u16::MAX as u32
720+
})
719721
{
720722
leading_simple_transition_count += 1;
721-
leading_simple_transition_character_count += chars.range_count();
723+
leading_simple_transition_range_count += chars.range_count();
722724
} else {
723725
break;
724726
}
725727
}
726728

727-
if leading_simple_transition_character_count >= 8 {
729+
if leading_simple_transition_range_count >= 8 {
728730
add_line!(self, "ADVANCE_MAP(");
729731
indent!(self);
730732
for (chars, action) in &state.advance_actions[0..leading_simple_transition_count] {
731733
for range in chars.ranges() {
732734
add_whitespace!(self);
733735
self.add_character(*range.start());
734736
add!(self, ", {},\n", action.state);
737+
if range.end() > range.start() {
738+
add_whitespace!(self);
739+
self.add_character(*range.end());
740+
add!(self, ", {},\n", action.state);
741+
}
735742
}
736743
ruled_out_chars = ruled_out_chars.add(chars);
737744
}

0 commit comments

Comments
 (0)