From 4fe9daec03db7806073614cf1a4bd83dcd43fcd5 Mon Sep 17 00:00:00 2001 From: Qstick Date: Mon, 9 Jan 2023 22:05:54 -0600 Subject: [PATCH] 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. --- .editorconfig | 1 - src/NzbDrone.Common/OAuth/WebParameterCollection.cs | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.editorconfig b/.editorconfig index 14d87d1b0..09580cb96 100644 --- a/.editorconfig +++ b/.editorconfig @@ -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 diff --git a/src/NzbDrone.Common/OAuth/WebParameterCollection.cs b/src/NzbDrone.Common/OAuth/WebParameterCollection.cs index a1084a0ef..5f905872e 100644 --- a/src/NzbDrone.Common/OAuth/WebParameterCollection.cs +++ b/src/NzbDrone.Common/OAuth/WebParameterCollection.cs @@ -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; }