Skip to content

Speed up comment presence checks#799

Merged
reese merged 1 commit intotrunkfrom
reese-comment-offsets
Jan 18, 2026
Merged

Speed up comment presence checks#799
reese merged 1 commit intotrunkfrom
reese-comment-offsets

Conversation

@reese
Copy link
Collaborator

@reese reese commented Jan 18, 2026

This addresses two sources of slowness in our comment handling. First, has_comment_in_offsets is being stored in a HashSet, but in has_comment_in_offsets -- the only place we use this -- we just iterate through all of them anyways, making the HashSet redundant. We can use a Vec instead and avoid the hashing overhead.

And now that have the offsets in a hash, and because they're naturally sorted since we're inserting them in-order, we can then binary search for the offset instead of iterating through everything, which is O(log n) instead of O(n).

Copy link
Collaborator

@froydnj froydnj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@reese reese merged commit 555f117 into trunk Jan 18, 2026
8 checks passed
@reese reese deleted the reese-comment-offsets branch January 18, 2026 00:50
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