-
Notifications
You must be signed in to change notification settings - Fork 470
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
Improve performance of spell checking analyzer #6569
Conversation
/// Todo, use an actual AdditionalTextValueProvider once it is available: | ||
/// https://github.com/dotnet/roslyn/issues/67611 | ||
/// </summary> | ||
private readonly ConditionalWeakTable<AdditionalText, CodeAnalysisDictionary> _textToDictionary = new(); |
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.
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.
Correct. Manish preferred non-static CWTs for additional-text mappings.
|
||
return dictionary; | ||
|
||
// Local function to avoid unnecessary lambda alloc in mainline case. |
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.
❔ Wouldn't it only need to alloc the lambda if the lambda references additionalText
from the containing scope? In this case, it only seems to reference dictionary
from the current scope.
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.
I'll check the IL, but i believe it will still create a closure.
=> !projectDictionary.UnrecognizedWords.Contains(word) && projectDictionary.RecognizedWords.Contains(word); | ||
{ | ||
var unrecognizedWordsContains = dictionaries.Any(static (d, word) => d.ContainsUnrecognizedWord(word), word); | ||
var recognizedWordsContains = dictionaries.Any(static (d, word) => d.ContainsRecognizedWord(word), word); |
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.
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.
no. it would def make sense to shortcircuit. i'll do that.
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #6569 +/- ##
=======================================
Coverage 96.43% 96.43%
=======================================
Files 1373 1373
Lines 320341 320260 -81
Branches 10309 10296 -13
=======================================
- Hits 308911 308837 -74
+ Misses 8972 8966 -6
+ Partials 2458 2457 -1 |
Addresses the enormous amount of dictionary allocations performed on every compilation start: