-
Notifications
You must be signed in to change notification settings - Fork 225
Fix perf of multiline semantic tokens, and LF handling of same #8828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| 1 0 19 razorComment 0 | ||
| 1 0 3 razorComment 0 | ||
| 0 3 1 razorCommentStar 0 | ||
| 0 1 1 razorCommentTransition 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Importantly, with the previous code, this test snapshot file and the above test snapshot file were different, which is the bug this is fixing. All other test snapshots are unchanged because the rest is just perf work.
...Microsoft.AspNetCore.Razor.LanguageServer/Semantic/Services/TagHelperSemanticRangeVisitor.cs
Show resolved
Hide resolved
...Microsoft.AspNetCore.Razor.LanguageServer/Semantic/Services/TagHelperSemanticRangeVisitor.cs
Outdated
Show resolved
Hide resolved
| // Blank line. The less than check is important because we could have seen two newline characters, but | ||
| // be in a situation where we have an LF file with multiple blank lines, so endChar would be -1. Still | ||
| // a blank line though :) | ||
| if (endChar <= 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ would it make more sense to have GetLastNonWhitespaceCharacterOffset not return a negative number? Will comment below on proposed change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, thank you! Couldn't see the forrest for the trees :)
| lineLength--; | ||
|
|
||
| var lineEndAbsoluteIndex = lineStartAbsoluteIndex + lineLength; | ||
| if (lineEndAbsoluteIndex == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (lineEndAbsoluteIndex == 0) | |
| if (lineEndAbsoluteIndex == 0 || lineLength == 0) |
Fixes #6756
Fixes #8176
The compiler team fixed the perf of
GetContent()in #8032 but we were still being pretty naive in our usage here, and the use ofEnvironment.NewLinewas just wrong.Results show no harm without a large comment, but a big saving in allocations when there is a large comment.
Old:
New: