From 6827ac5670ca05b3237b2aed2f8d3ae34f89cd05 Mon Sep 17 00:00:00 2001 From: Qstick Date: Mon, 9 Jan 2023 22:18:14 -0600 Subject: [PATCH] Use span-based string.Concat to avoid unnecessary allocation Calling Substring produces a copy of the extracted substring. By using AsSpan instead of Substring and calling the overload of string.Concat that accepts spans, you can eliminate the unnecessary string allocation. (cherry picked from commit e8aff90582fb50b2d48dea3a4c2139c2745f1554) Fixes #2262 --- src/NzbDrone.Common/Http/HttpUri.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NzbDrone.Common/Http/HttpUri.cs b/src/NzbDrone.Common/Http/HttpUri.cs index 647da04ee..9cc3b8fec 100644 --- a/src/NzbDrone.Common/Http/HttpUri.cs +++ b/src/NzbDrone.Common/Http/HttpUri.cs @@ -170,7 +170,7 @@ namespace NzbDrone.Common.Http if (baseSlashIndex >= 0) { - return basePath.Substring(0, baseSlashIndex) + "/" + relativePath; + return $"{basePath.AsSpan(0, baseSlashIndex)}/{relativePath}"; } return relativePath;