🐇 Avoid computing unnecessary semantic models#43566
Conversation
| { | ||
| var importsToAdd = ArrayBuilder<SyntaxNode>.GetInstance(); | ||
|
|
||
| var model = await document.GetRequiredSemanticModelAsync(cancellationToken).ConfigureAwait(false); |
There was a problem hiding this comment.
if this is always going to do this work (and pass back out) , i don't get why it woudln't be nicer to just have the caller compute this andpass in.
There was a problem hiding this comment.
It pushes a bunch of implementation knowledge up to the caller. The deconstruction assignment and switch expression would both be eliminated. This call would need to compute in advance, while the other call does not compute in advance but might compute in the implementation.
There was a problem hiding this comment.
I can implement this change if you want to see it. I felt like the additional noise didn't make it worth it.
There was a problem hiding this comment.
it just feels weird to have it not passed in, always computed, and passed out so the caller wil have it...
Significantly improves the performance BatchFixAllProvider when imports do not need to be added.
For one sample project, the Fix All in Solution performance for Roslyn.sln dropped from over one hour (cancelled before completion) to less than 30 seconds.