From 7521579bca1effb31e3d02418c853b28f6c5007b Mon Sep 17 00:00:00 2001 From: Qstick Date: Mon, 9 Jan 2023 22:10:57 -0600 Subject: [PATCH] Use Apend(char) instead of Apend(string) for performance When calling StringBuilder.Append with a unit length string, consider using a const char rather than a unit length const string to improve performance. --- .editorconfig | 1 - src/NzbDrone.Common/Http/HttpUri.cs | 8 ++++---- src/NzbDrone.Core/Extras/Subtitles/SubtitleService.cs | 6 +++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.editorconfig b/.editorconfig index 8a02d7e30..ab2e60a64 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.CA1834.severity = suggestion dotnet_diagnostic.CA1839.severity = suggestion dotnet_diagnostic.CA1840.severity = suggestion dotnet_diagnostic.CA1845.severity = suggestion diff --git a/src/NzbDrone.Common/Http/HttpUri.cs b/src/NzbDrone.Common/Http/HttpUri.cs index 647da04ee..ecd4abf70 100644 --- a/src/NzbDrone.Common/Http/HttpUri.cs +++ b/src/NzbDrone.Common/Http/HttpUri.cs @@ -27,7 +27,7 @@ namespace NzbDrone.Common.Http if (scheme.IsNotNullOrWhiteSpace()) { builder.Append(scheme); - builder.Append(":"); + builder.Append(':'); } if (host.IsNotNullOrWhiteSpace()) @@ -36,7 +36,7 @@ namespace NzbDrone.Common.Http builder.Append(host); if (port.HasValue) { - builder.Append(":"); + builder.Append(':'); builder.Append(port); } } @@ -202,11 +202,11 @@ namespace NzbDrone.Common.Http { if (builder.Length != 0) { - builder.Append("&"); + builder.Append('&'); } builder.Append(Uri.EscapeDataString(pair.Key)); - builder.Append("="); + builder.Append('='); builder.Append(Uri.EscapeDataString(pair.Value)); } diff --git a/src/NzbDrone.Core/Extras/Subtitles/SubtitleService.cs b/src/NzbDrone.Core/Extras/Subtitles/SubtitleService.cs index e929574a5..c96f2ef14 100644 --- a/src/NzbDrone.Core/Extras/Subtitles/SubtitleService.cs +++ b/src/NzbDrone.Core/Extras/Subtitles/SubtitleService.cs @@ -234,19 +234,19 @@ namespace NzbDrone.Core.Extras.Subtitles if (multipleCopies) { - suffixBuilder.Append("."); + suffixBuilder.Append('.'); suffixBuilder.Append(copy); } if (language != Language.Unknown) { - suffixBuilder.Append("."); + suffixBuilder.Append('.'); suffixBuilder.Append(IsoLanguages.Get(language).TwoLetterCode); } if (languageTags.Any()) { - suffixBuilder.Append("."); + suffixBuilder.Append('.'); suffixBuilder.Append(string.Join(".", languageTags)); }