Skip to content

Commit 4725e36

Browse files
authored
Remove null checks from Path.CombineInternal (dotnet#119922)
All the arguments are validated not null in the public constructors.
1 parent 84e3a2b commit 4725e36

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

  • src/libraries/System.Private.CoreLib/src/System/IO

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -650,10 +650,10 @@ public static bool TryJoin(ReadOnlySpan<char> path1, ReadOnlySpan<char> path2, R
650650

651651
private static string CombineInternal(string first, string second)
652652
{
653-
if (string.IsNullOrEmpty(first))
653+
if (first.Length == 0)
654654
return second;
655655

656-
if (string.IsNullOrEmpty(second))
656+
if (second.Length == 0)
657657
return first;
658658

659659
if (IsPathRooted(second.AsSpan()))
@@ -664,11 +664,11 @@ private static string CombineInternal(string first, string second)
664664

665665
private static string CombineInternal(string first, string second, string third)
666666
{
667-
if (string.IsNullOrEmpty(first))
667+
if (first.Length == 0)
668668
return CombineInternal(second, third);
669-
if (string.IsNullOrEmpty(second))
669+
if (second.Length == 0)
670670
return CombineInternal(first, third);
671-
if (string.IsNullOrEmpty(third))
671+
if (third.Length == 0)
672672
return CombineInternal(first, second);
673673

674674
if (IsPathRooted(third.AsSpan()))
@@ -681,13 +681,13 @@ private static string CombineInternal(string first, string second, string third)
681681

682682
private static string CombineInternal(string first, string second, string third, string fourth)
683683
{
684-
if (string.IsNullOrEmpty(first))
684+
if (first.Length == 0)
685685
return CombineInternal(second, third, fourth);
686-
if (string.IsNullOrEmpty(second))
686+
if (second.Length == 0)
687687
return CombineInternal(first, third, fourth);
688-
if (string.IsNullOrEmpty(third))
688+
if (third.Length == 0)
689689
return CombineInternal(first, second, fourth);
690-
if (string.IsNullOrEmpty(fourth))
690+
if (fourth.Length == 0)
691691
return CombineInternal(first, second, third);
692692

693693
if (IsPathRooted(fourth.AsSpan()))

0 commit comments

Comments
 (0)