Skip to content

perf(scanner): fast-path identifier characters and short-circuit keyword scans#5

Merged
DylanPiercey merged 1 commit into
mainfrom
claude/htmljs-parser-tree-sitter-fixes-dm8wj0
Jun 26, 2026
Merged

perf(scanner): fast-path identifier characters and short-circuit keyword scans#5
DylanPiercey merged 1 commit into
mainfrom
claude/htmljs-parser-tree-sitter-fixes-dm8wj0

Conversation

@DylanPiercey

Copy link
Copy Markdown
Contributor

Ports the expression fast paths from marko-js/htmljs-parser#223 (commit 3c95d7f) to the external scanner:

  • Identifier/number-character fast path in the expression loop — a word character is never whitespace, never a terminator, and never a switch case, so it skips the per-character termination checks (including should_terminate's eager lookahead) and the switch dispatch and just advances.
  • Keyword-scan short-circuitlook_behind_for_operator / look_ahead_for_operator bail out immediately when the boundary character can't start/end a keyword (every keyword is lowercase ASCII).

No behavior change — the 372-fixture comparison suite passes identically. Measured ~6–9% faster on expression-heavy input in an A/B build (matching the ~6% reported upstream).


Generated by Claude Code

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@DylanPiercey, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 40 minutes and 29 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 35bcb231-b1bd-40f8-9b4f-c46a3d4de153

📥 Commits

Reviewing files that changed from the base of the PR and between dd3f38d and 9e15dd6.

📒 Files selected for processing (1)
  • src/scanner.c

Walkthrough

src/scanner.c now short-circuits unary and binary operator keyword matching when the inspected character is outside lowercase ASCII. The expression scanner also adds a direct path for characters that satisfy is_word_code, advancing past them before the termination and switch-dispatch logic.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main scanner performance change: fast-path character handling and keyword scan short-circuiting.
Description check ✅ Passed The description is directly related to the changeset and matches the reported scanner fast paths and performance goal.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/htmljs-parser-tree-sitter-fixes-dm8wj0

Comment @coderabbitai help to get the list of available commands.

…ord scans

Port htmljs-parser's EXPRESSION fast paths to the external scanner:

- Add an identifier/number-character fast path to the expression loop. Such a
  character is never whitespace, never a terminator (no should_terminate case
  matches a word character), and is not one of the switch's cases, so it
  short-circuits the termination checks (including should_terminate's eager
  lookahead) and the switch dispatch and just advances.
- Bail out of the unary/binary operator keyword scans immediately when the
  surrounding character cannot start or end a keyword (every keyword is
  lowercase ASCII letters).

No behavior change: the full fixture-comparison suite passes. ~6-9% faster on
expression-heavy input in an A/B build.

Mirrors marko-js/htmljs-parser#223 (commit 3c95d7f).
@DylanPiercey
DylanPiercey force-pushed the claude/htmljs-parser-tree-sitter-fixes-dm8wj0 branch from dd3f38d to 9e15dd6 Compare June 26, 2026 04:57
@DylanPiercey
DylanPiercey merged commit 315e866 into main Jun 26, 2026
8 checks passed
@DylanPiercey
DylanPiercey deleted the claude/htmljs-parser-tree-sitter-fixes-dm8wj0 branch June 26, 2026 14:01
@github-project-automation github-project-automation Bot moved this to Done in Roadmap Jun 29, 2026
@DylanPiercey DylanPiercey self-assigned this Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant