Optimize Prism::Source#find_line#3758
Merged
Merged
Conversation
This is more concise and ruby does a better job performance-wise. This used to be `bsearch_index` already but ruby@6d8358c changed it. ruby#1733 (comment) said: > Yeah the edge case was that the value matched an element exactly But surely there would be a test to show this behaviour? Gets called as part of pretty-printing nodes. Further reduces the time for `SnapshotsTest` by ~16% for me.
Collaborator
|
If I recall correctly, it was getting the wrong line number when the bounds of the node hit the newline exactly. I think maybe heredocs were the issue? I'm surprised to see none of the snapshots change though. I'm going to optimistically merge this and hope things are fine assuming this is good. |
kddnewton
approved these changes
Nov 29, 2025
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.
This is more concise and ruby does a better job performance-wise.
This used to be
bsearch_indexalready but 6d8358c changed it. #1733 (comment) said:But surely there would be a test to show this behaviour?
Gets called as part of pretty-printing nodes.
Further reduces the time for
SnapshotsTestby ~16% for me.