Skip to content

perf: speed up inline-comment diff rendering with integer-keyed index#99

Merged
watany-dev merged 1 commit into
mainfrom
claude/benchmark-optimize-perf-pqmdlw
Jun 22, 2026
Merged

perf: speed up inline-comment diff rendering with integer-keyed index#99
watany-dev merged 1 commit into
mainfrom
claude/benchmark-optimize-perf-pqmdlw

Conversation

@watany-dev

Copy link
Copy Markdown
Owner

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

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
@watany-dev watany-dev merged commit dd67a72 into main Jun 22, 2026
6 of 7 checks passed
@watany-dev watany-dev deleted the claude/benchmark-optimize-perf-pqmdlw branch June 22, 2026 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants