mirror of
https://github.com/Readarr/Readarr
synced 2025-12-28 19:22:57 +01:00
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
This commit is contained in:
parent
0572bde41e
commit
6827ac5670
1 changed files with 1 additions and 1 deletions
|
|
@ -170,7 +170,7 @@ private static string CombineRelativePath(string basePath, string relativePath)
|
|||
|
||||
if (baseSlashIndex >= 0)
|
||||
{
|
||||
return basePath.Substring(0, baseSlashIndex) + "/" + relativePath;
|
||||
return $"{basePath.AsSpan(0, baseSlashIndex)}/{relativePath}";
|
||||
}
|
||||
|
||||
return relativePath;
|
||||
|
|
|
|||
Loading…
Reference in a new issue