perf: speed up inline-comment diff rendering with integer-keyed index#99
Merged
Merged
Conversation
buildDisplayLines previously concatenated a `filePath:line:version` string key for every diff line and looked it up in a flat Map. For PRs with inline comments this allocated a key string per rendered line on every rebuild. Index inline threads per file, bucketed by line number for each version, so the diff loop resolves anchors with integer Map lookups and skips files that have no inline threads entirely. Bench (10 files × 200 lines, 50 inline threads, warm cache) improves ~5x. Also avoid redundant full-array slice copies in the cold cache path when the display limit already covers the whole file, and hoist array lengths out of the computeSimpleDiff hot loop. Output is unchanged; covered by a new displayLines unit test for BEFORE-anchored and same-line threads. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CgM5n6y7wNoBjbjWvfFdHb
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.
buildDisplayLines previously concatenated a
filePath:line:versionstringkey for every diff line and looked it up in a flat Map. For PRs with inline
comments this allocated a key string per rendered line on every rebuild.
Index inline threads per file, bucketed by line number for each version, so
the diff loop resolves anchors with integer Map lookups and skips files that
have no inline threads entirely. Bench (10 files × 200 lines, 50 inline
threads, warm cache) improves ~5x.
Also avoid redundant full-array slice copies in the cold cache path when the
display limit already covers the whole file, and hoist array lengths out of
the computeSimpleDiff hot loop. Output is unchanged; covered by a new
displayLines unit test for BEFORE-anchored and same-line threads.
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01CgM5n6y7wNoBjbjWvfFdHb