Skip to content
Source
Sign inSign up
TanStack/highlight

perf: scan object expression identifiers once #45

Mergedtannerlinsleymerged 1 commit intomain fromtaren/highlight-lexical-eventsmerged by tannerlinsley

tannerlinsleycommented

Consume each identifier once while scanning JavaScript and TypeScript object expressions. Previously, identifiers that were not property keys revisited their remaining characters, repeating brace-context and previous-code checks. The scanner now resumes at the next delimiter, while property detection and later semantic matching stay unchanged.

Repeated complete highlighting of the 334 documentation fixtures takes about 3% less time on Node 24. The JSX fixtures improve about 7% in both runs. Bun results are positive but noisier, so no universal Bun speedup is claimed. Two reversed allocation pairs over completed documentation highlighting show about 2.3% and 3.2% less sampled V8 allocation.

Local validation passes 367 tests, 17,498 completed-result compatibility cases, 30,670 JS/TS/JSX/TSX semantic fuzz cases, all 12 normal validation gates, and all existing size/runtime budgets. Regression coverage includes nested objects, methods, comments, templates, regexes, spread identifiers and JSX following identifiers.

The full bundle changes by -5 minified, +4 gzip and +55 Brotli bytes. All budgets remain unchanged, including the Octane gzip limit, which has 5 bytes of remaining headroom. Independent C integration passes all 12 gates and 384 tests. Focused object-context checks pass 12,800 public-result and raw-range comparisons on each of Node and Bun, including unchanged range order. Fifteen fresh cold-start pairs show no material regression, and nine fresh retained-heap pairs have identical import, first-work and total retained-heap medians. Exact-head CI passes Node 18, 20, 22, 24 and 26, and the review check succeeds with no inline findings. Includes a patch changeset.

    1. 🦋 Changeset detected

      Latest commit: cb5e750e7da28bb3e7c8d800f693d5705e43242f

      The changes in this PR will be included in the next version bump.

      This PR includes changesets to release 1 package
      NameType
      @tanstack/highlightPatch

      Not sure what this means? Click here to learn what changesets are.

      Click here if you're a maintainer who wants to add another changeset to this PR

    2. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      No actionable comments were generated in the recent review.

      Recent review info
      Run configuration
      • Source mode: Auto
      • Repository: Unavailable
      • Branch: Unavailable
      • File: No configuration file from this repository applied
      • Commit: Unavailable
      • Layers: defaults
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: b3bab1e3-2663-4184-9254-0825d0220f5d
      Commits

      Reviewing files that changed from the base of the PR and between 31222bc0b8160897efb8ccd9e12bd7c617617b42 and cb5e750e7da28bb3e7c8d800f693d5705e43242f.

      Files selected for processing: 3
      • .changeset/object-identifier-stride.md
      • src/internal/script.ts
      • test/regressions.test.ts

      Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

      Walkthrough

      The scanner now advances past identifiers inside object braces even when they are not classified as properties. Regression tests cover token reconstruction and classifications across JavaScript, TypeScript, JSX, and TSX.

      Changes: Object identifier scanning

      Layer / File(s)Summary
      Scan identifiers and validate tokenization
      src/internal/script.ts, test/regressions.test.ts, .changeset/object-identifier-stride.md
      The scanner advances past each identifier while retaining the existing property checks. Regression tests cover object keys, methods, nested objects, templates, regex literals, spreads, dollar-prefixed keys, and JSX/TSX tags. A patch changeset records the update.

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Refactor

      Possibly related PRs

      • TanStack/highlight#41: Changes the scanner pipeline and src/internal/script.ts for performance in the same JavaScript and TypeScript scanning path.
      Merge Risk: Minimal · up to cb5e7

      The optimization preserves tokenization and highlighting behavior across the supported JavaScript and TypeScript language paths.

      Pre-merge checks: Passed 4 · Failed 1
      Failed Failed checks: 1 warning
      Check nameStatusExplanationResolution
      Docstring CoverageWarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…Write docstrings for the functions missing them to satisfy the coverage threshold.
      Passed Passed checks: 4 passed
      Check nameStatusExplanation
      Title checkPassedThe title "perf: scan object expression identifiers once" matches the main change. The raw summary and objectives say the scanner now consumes each identifier once inside JS/TS object expressions, whi…
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
      Description checkPassedThe description provides the required change rationale and detailed validation results, including regression coverage, benchmarks, size impact, and test outcomes. It does not use the template headings…
      Full details: Title check

      Explanation

      The title "perf: scan object expression identifiers once" matches the main change. The raw summary and objectives say the scanner now consumes each identifier once inside JS/TS object expressions, which is the core of the PR. The title is short, specific, and follows a conventional commit style.

      Full details: Description check

      Explanation

      The description provides the required change rationale and detailed validation results, including regression coverage, benchmarks, size impact, and test outcomes. It does not use the template headings explicitly, but it is complete and clearly covers both required sections.

      Full details: Docstring Coverage

      Explanation

      Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files. (1 skipped: 1 unsupported.)

      Resolution

      Write docstrings for the functions missing them to satisfy the coverage threshold.

      Finishing Touches
      Generate docstrings
      • Commit to this branch
      • Create a new PR
      Generate unit tests (beta)
      • Commit to this branch
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      Share
    3. tannerlinsley merged thisc133368

    4. tannerlinsley closed this

Sign in to join this conversation.