Skip to content

Commit 90d1387

Browse files
committed
Simplify 2 ROS overload
1 parent 1408a82 commit 90d1387

File tree

1 file changed

+6
-4
lines changed
  • src/libraries/System.Private.CoreLib/src/System/IO

1 file changed

+6
-4
lines changed

src/libraries/System.Private.CoreLib/src/System/IO/Path.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -646,13 +646,14 @@ private static unsafe string JoinInternal(ReadOnlySpan<char> first, ReadOnlySpan
646646
bool hasSeparator = PathInternal.IsDirectorySeparator(first[first.Length - 1])
647647
|| PathInternal.IsDirectorySeparator(second[0]);
648648

649+
#if !MS_IO_REDIST
650+
return hasSeparator ?
651+
string.Concat(first, second) :
652+
string.Concat(first, PathInternal.DirectorySeparatorCharAsString, second);
653+
#else
649654
fixed (char* f = &MemoryMarshal.GetReference(first), s = &MemoryMarshal.GetReference(second))
650655
{
651-
#if MS_IO_REDIST
652656
return StringExtensions.Create(
653-
#else
654-
return string.Create(
655-
#endif
656657
first.Length + second.Length + (hasSeparator ? 0 : 1),
657658
(First: (IntPtr)f, FirstLength: first.Length, Second: (IntPtr)s, SecondLength: second.Length),
658659
static (destination, state) =>
@@ -663,6 +664,7 @@ private static unsafe string JoinInternal(ReadOnlySpan<char> first, ReadOnlySpan
663664
new Span<char>((char*)state.Second, state.SecondLength).CopyTo(destination.Slice(destination.Length - state.SecondLength));
664665
});
665666
}
667+
#endif
666668
}
667669

668670
private unsafe readonly struct Join3Payload

0 commit comments

Comments
 (0)