Skip to content

Commit

Permalink
Merge pull request #6869 from Youssef1313/length-instead-of-count
Browse files Browse the repository at this point in the history
[Performance] Use Length property instead of Count()
  • Loading branch information
mavasani authored Aug 28, 2023
2 parents b43c3aa + 56aa98c commit 2d42aa2
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information.

using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using Microsoft.CodeAnalysis;

Expand Down Expand Up @@ -44,7 +43,7 @@ public static IEnumerable<IMethodSymbol> GetMethodOverloadsWithDesiredParameterA
{
return methods.Where(candidateMethod =>
{
if (!System.Collections.Immutable.ImmutableArrayExtensions.HasExactly(candidateMethod.Parameters, selectedOverload.Parameters.Count() + 1))
if (!System.Collections.Immutable.ImmutableArrayExtensions.HasExactly(candidateMethod.Parameters, selectedOverload.Parameters.Length + 1))
{
return false;
}
Expand All @@ -70,7 +69,7 @@ public static IEnumerable<IMethodSymbol> GetMethodOverloadsWithDesiredParameterA
}
}

for (int i = 0; i < selectedOverload.Parameters.Count(); i++, j++)
for (int i = 0; i < selectedOverload.Parameters.Length; i++, j++)
{
if (!selectedOverload.Parameters[i].Type.Equals(candidateMethod.Parameters[j].Type) ||
selectedOverload.Parameters[i].IsParams != candidateMethod.Parameters[j].IsParams ||
Expand Down Expand Up @@ -140,7 +139,7 @@ public static IEnumerable<IMethodSymbol> GetMethodOverloadsWithDesiredParameterA
var expectedParameterCount = expectedParameterTypesInOrder.Length;
return members?.FirstOrDefault(member =>
{
if (member.Parameters.Count() != expectedParameterCount)
if (member.Parameters.Length != expectedParameterCount)
{
return false;
}
Expand Down

0 comments on commit 2d42aa2

Please sign in to comment.