Skip to content

Commit 8275f7e

Browse files
authored
Merge pull request #209 from structuredllm/fixbyte
Fix the Byte FSM bug
2 parents d947182 + ea389df commit 8275f7e

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

syncode/mask_store/byte_fsm.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -341,18 +341,14 @@ def consume_prefix(self, data: Union[str, bytes], current_state: Optional[Any] =
341341
if not state_transitions: # No transitions - dead state
342342
break
343343

344-
# Direct byte transition - most common case first
345-
if byte in state_transitions:
346-
cur_state = state_transitions[byte]
344+
# Only get category if needed - reduces _get_category calls
345+
category = self._get_category(byte)
346+
if category is not None and category in state_transitions:
347+
cur_state = state_transitions[category]
347348
else:
348-
# Only get category if needed - reduces _get_category calls
349-
category = self._get_category(byte)
350-
if category is not None and category in state_transitions:
351-
cur_state = state_transitions[category]
352-
else:
353-
# No valid transition - we've reached a "dead" state
354-
cur_state = None
355-
break
349+
# No valid transition - we've reached a "dead" state
350+
cur_state = None
351+
break
356352

357353
# Check if we're in a final state - using cached method
358354
if is_final(cur_state):

0 commit comments

Comments
 (0)