From 2b79fe833b3fdc48d52eca43bbddc64954ff0c13 Mon Sep 17 00:00:00 2001 From: Qstick Date: Mon, 9 Jan 2023 22:24:35 -0600 Subject: [PATCH] Use Contains(char) instead of Contains(string) for performance --- .editorconfig | 1 - src/NzbDrone.Common/Extensions/StringExtensions.cs | 4 ++-- .../Datastore/Migration/163_mediainfo_to_ffmpeg.cs | 4 ++-- src/NzbDrone.Core/Localization/LocalizationService.cs | 2 +- src/NzbDrone.Core/Parser/SceneChecker.cs | 4 ++-- src/Sonarr.Http/Frontend/Mappers/IndexHtmlMapper.cs | 2 +- 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.editorconfig b/.editorconfig index 74bee9b59..318420b04 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.CA1847.severity = suggestion dotnet_diagnostic.CA2000.severity = suggestion dotnet_diagnostic.CA2002.severity = suggestion dotnet_diagnostic.CA2007.severity = suggestion diff --git a/src/NzbDrone.Common/Extensions/StringExtensions.cs b/src/NzbDrone.Common/Extensions/StringExtensions.cs index 2bdb5406c..75e5462f4 100644 --- a/src/NzbDrone.Common/Extensions/StringExtensions.cs +++ b/src/NzbDrone.Common/Extensions/StringExtensions.cs @@ -131,7 +131,7 @@ namespace NzbDrone.Common.Extensions public static string WrapInQuotes(this string text) { - if (!text.Contains(" ")) + if (!text.Contains(' ')) { return text; } @@ -240,7 +240,7 @@ namespace NzbDrone.Common.Extensions public static string ToUrlHost(this string input) { - return input.Contains(":") ? $"[{input}]" : input; + return input.Contains(':') ? $"[{input}]" : input; } } } diff --git a/src/NzbDrone.Core/Datastore/Migration/163_mediainfo_to_ffmpeg.cs b/src/NzbDrone.Core/Datastore/Migration/163_mediainfo_to_ffmpeg.cs index 6fcc45a7d..7889666d5 100644 --- a/src/NzbDrone.Core/Datastore/Migration/163_mediainfo_to_ffmpeg.cs +++ b/src/NzbDrone.Core/Datastore/Migration/163_mediainfo_to_ffmpeg.cs @@ -627,13 +627,13 @@ namespace NzbDrone.Core.Datastore.Migration try { - if (audioChannelPositions.Contains("+")) + if (audioChannelPositions.Contains('+')) { return audioChannelPositions.Split('+') .Sum(s => decimal.Parse(s.Trim(), CultureInfo.InvariantCulture)); } - if (audioChannelPositions.Contains("/")) + if (audioChannelPositions.Contains('/')) { var channelStringList = Regex.Replace(audioChannelPositions, @"^\d+\sobjects", diff --git a/src/NzbDrone.Core/Localization/LocalizationService.cs b/src/NzbDrone.Core/Localization/LocalizationService.cs index aefe7c04b..aa184e6dd 100644 --- a/src/NzbDrone.Core/Localization/LocalizationService.cs +++ b/src/NzbDrone.Core/Localization/LocalizationService.cs @@ -133,7 +133,7 @@ namespace NzbDrone.Core.Localization await CopyInto(dictionary, baseFilenamePath).ConfigureAwait(false); - if (culture.Contains("_")) + if (culture.Contains('_')) { var languageBaseFilenamePath = Path.Combine(prefix, GetResourceFilename(culture.Split('_')[0])); await CopyInto(dictionary, languageBaseFilenamePath).ConfigureAwait(false); diff --git a/src/NzbDrone.Core/Parser/SceneChecker.cs b/src/NzbDrone.Core/Parser/SceneChecker.cs index 2ecd20fb5..a09a11daa 100644 --- a/src/NzbDrone.Core/Parser/SceneChecker.cs +++ b/src/NzbDrone.Core/Parser/SceneChecker.cs @@ -6,12 +6,12 @@ // It's better not to use a title that might be scene than to use one that isn't scene public static bool IsSceneTitle(string title) { - if (!title.Contains(".")) + if (!title.Contains('.')) { return false; } - if (title.Contains(" ")) + if (title.Contains(' ')) { return false; } diff --git a/src/Sonarr.Http/Frontend/Mappers/IndexHtmlMapper.cs b/src/Sonarr.Http/Frontend/Mappers/IndexHtmlMapper.cs index 79d5d326f..d8cbaab63 100644 --- a/src/Sonarr.Http/Frontend/Mappers/IndexHtmlMapper.cs +++ b/src/Sonarr.Http/Frontend/Mappers/IndexHtmlMapper.cs @@ -35,7 +35,7 @@ namespace Sonarr.Http.Frontend.Mappers return !resourceUrl.StartsWith("/content") && !resourceUrl.StartsWith("/mediacover") && - !resourceUrl.Contains(".") && + !resourceUrl.Contains('.') && !resourceUrl.StartsWith("/login"); } }