Commits
Click on a commit to change the comparison rangeperf: optimize state machine with Top state fast path
Restructured the main state machine loop to check for the Top state
first using a simple equality check instead of a match statement.
Since Top is the most common state when processing JSON, this
optimization improves branch prediction and reduces comparisons.
Performance improvements:
- minimal_comments: ~14% faster (122ns → 106ns)
- large_with_comments: ~16% faster (12.2µs → 10.4µs)
- no_comments: ~3% faster (482ns → 472ns)
- tsconfig: ~1% faster
The optimization works by:
1. Checking `if *state == Top` first (branch-prediction friendly)
2. Handling less common states in the else branch
3. Reducing pattern matching overhead for the common case
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>