SonarSource / sonar-dotnet

Code analyzer for C# and VB.NET projects
https://redirect.sonarsource.com/plugins/csharp.html
GNU Lesser General Public License v3.0
794 stars 228 forks source link

S2971 Improve performance: CollectionQuerySimplification #3731

Open pavel-mikula-sonarsource opened 4 years ago

pavel-mikula-sonarsource commented 4 years ago

As a side effect of https://discuss.sonarsource.com/t/slow-c-analysis/6329, CollectionQuerySimplification took 5% of analysis time.

We can improve the implementation by sharing the methodSymbol between all 3 checks and by checking the name from syntax before querying the symbol.

andrei-epure-sonarsource commented 3 years ago

Another community topic where

166.327   97   SonarAnalyzer.CSharp, 
10.102    5      SonarAnalyzer.Rules.CSharp.CollectionQuerySimplification
pavel-mikula-sonarsource commented 3 years ago

There should be single registration for SyntaxKind.InvocationExpression instead of 3. CheckCountCall is fast. CheckExtensionMethodsOnIEnumerable and CheckToCollectionCalls are slow and could share some parts.