Use Any() in place of Count() to prevent enumerating

This rule flags the Count and LongCount LINQ method calls used to check if the collection has at least one element. These method calls require enumerating the entire collection to compute the count. The same check is faster with the Any method as it avoids enumerating the collection.
This commit is contained in:
Qstick 2023-01-09 22:05:54 -06:00
parent 738dc2c98c
commit 4fe9daec03
2 changed files with 2 additions and 2 deletions

View File

@ -194,7 +194,6 @@ dotnet_diagnostic.CA1819.severity = suggestion
dotnet_diagnostic.CA1822.severity = suggestion
dotnet_diagnostic.CA1823.severity = suggestion
dotnet_diagnostic.CA1824.severity = suggestion
dotnet_diagnostic.CA1827.severity = suggestion
dotnet_diagnostic.CA1829.severity = suggestion
dotnet_diagnostic.CA1834.severity = suggestion
dotnet_diagnostic.CA1839.severity = suggestion

View File

@ -3,6 +3,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using NzbDrone.Common.Extensions;
namespace NzbDrone.Common.OAuth
{
@ -16,7 +17,7 @@ namespace NzbDrone.Common.OAuth
{
var parameters = this.Where(p => p.Name.Equals(name));
if (parameters.Count() == 0)
if (parameters.Empty())
{
return null;
}