This repository was archived by the owner on Aug 31, 2023. It is now read-only.
perf(rome_rowan): SyntaxNodeText
improvements
#3217
Merged
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 PR improves the performance of
SyntaxNodeText
by using thetoken_at_offset
method rather than traversing over all tokens in the tree until it find the first token that has an overlapping range. Usingtoken_at_offset
has better performance because it only traverses into nodes that have an overlapping range.Example: Getting the text for
+ e
in ``a + b + c + d + e`+
token+
on the first level, then traverses intoe
Doing this improvement I discovered that
noShoutyConstants
usesSyntaxNodeText
overSyntaxTokenText
.SyntaxTokenText
has the better performance because it isn't necessary to find the first token with an overlapping range. So, I refactored the implementation to useSyntaxTokenText
insteadPerformance
Test Plan
I added new doc tests and integration tests for the changes in
rome_rowan
androme_text_size