Repository navigation
perf(javascript): skip the repeated-prefix scan on first capture visits - #1789
Merged
Merged
Conversation
Review follow-up. Only a capture already on the alias chain can repeat a prefix, so a first visit no longer slices and serializes every suffix of its path.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
10 tasks done
3 tasks done
Owner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #1767. That PR was merged before this commit, which answers the
review comment on the suffix scan, reached the branch.
collectSemanticMemberMutationsStepssearched every suffix of the current pathfor an earlier visit, even on a binding's first visit at a capture, where no
earlier visit can exist. The scan now runs only when the capture is already on
the alias chain.
Problem and expected behavior
For a deep write through many aliases with no projection
(
const a1 = a0; …; aB.p1…pL = 1), each alias is a first visit. The scan stillsliced and serialized all
Lsuffixes per alias, which is Θ(L²) per alias.Expected: a first visit does no suffix work.
Change and scope
Add a capture key to the alias chain's lifetime set and skip the scan when the
capture is absent. Behavior is unchanged: a suffix can only match an earlier
visit of the same capture.
Not included: the finite path expansion that dominates long self-alias chains
(see the measurements in #1767). It predates #1767 and needs its own fix.
Contract and boundary impact
docs/public/product-catalog.json), package, or installation impact: none.Evidence and regression coverage
results, and the existing self-alias and lifetime cases cover the scan's
outcomes.
with Node 24.18.0: 1.75 s on origin/main and 1.73 s with this change. The
scan is not the dominant cost at this size; the change removes its
quadratic term.
For evidence-bearing changes:
Validation performed
npx vitest run src/domain/javascript/— 43 files, 821 passednpm run check:fast— passedCompatibility, safety, and release
Review checklist
type(scope): outcome.🤖 Generated with Claude Code