if (second.Length == 0)
return new string(first);
- if (IsPathRooted(second)) // will change to span version after the span pr is merged
+ if (IsPathRooted(second))
return new string(second);
return CombineNoChecksInternal(first, second);
}
+ private static string CombineNoChecks(string first, string second)
+ {
+ if (string.IsNullOrEmpty(first))
+ return second;
+
+ if (string.IsNullOrEmpty(second))
+ return first;
+
+ if (IsPathRooted(second.AsReadOnlySpan()))
+ return second;
+
+ return CombineNoChecksInternal(first, second);
+ }
+
private static string CombineNoChecks(ReadOnlySpan<char> first, ReadOnlySpan<char> second, ReadOnlySpan<char> third)
{
if (first.Length == 0)
return CombineNoChecksInternal(first, second, third);
}
+ private static string CombineNoChecks(string first, string second, string third)
+ {
+ if (string.IsNullOrEmpty(first))
+ return CombineNoChecks(second, third);
+ if (string.IsNullOrEmpty(second))
+ return CombineNoChecks(first, third);
+ if (string.IsNullOrEmpty(third))
+ return CombineNoChecks(first, second);
+
+ if (IsPathRooted(third.AsReadOnlySpan()))
+ return third;
+ if (IsPathRooted(second.AsReadOnlySpan()))
+ return CombineNoChecks(second, third);
+
+ return CombineNoChecksInternal(first, second, third);
+ }
+
private static string CombineNoChecks(ReadOnlySpan<char> first, ReadOnlySpan<char> second, ReadOnlySpan<char> third, ReadOnlySpan<char> fourth)
{
if (first.Length == 0)
return CombineNoChecksInternal(first, second, third, fourth);
}
+ private static string CombineNoChecks(string first, string second, string third, string fourth)
+ {
+ if (string.IsNullOrEmpty(first))
+ return CombineNoChecks(second, third, fourth);
+ if (string.IsNullOrEmpty(second))
+ return CombineNoChecks(first, third, fourth);
+ if (string.IsNullOrEmpty(third));
+ return CombineNoChecks(first, second, fourth);
+ if (string.IsNullOrEmpty(fourth));
+ return CombineNoChecks(first, second, third);
+
+ if (IsPathRooted(fourth.AsReadOnlySpan()))
+ return fourth;
+ if (IsPathRooted(third.AsReadOnlySpan()))
+ return CombineNoChecks(third, fourth);
+ if (IsPathRooted(second.AsReadOnlySpan()))
+ return CombineNoChecks(second, third, fourth);
+
+ return CombineNoChecksInternal(first, second, third, fourth);
+ }
+
private unsafe static string CombineNoChecksInternal(ReadOnlySpan<char> first, ReadOnlySpan<char> second)
{
Debug.Assert(first.Length > 0 && second.Length > 0, "should have dealt with empty paths");