Skip to content

Commit 424f16b

Browse files
gfoidlgithub-actions
authored andcommitted
Don't use trick for collapsed epilogs
Cf. #67049 (comment)
1 parent b4dcd15 commit 424f16b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/libraries/System.Private.CoreLib/src/System/String.Manipulation.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -986,11 +986,13 @@ private string ReplaceCore(string oldValue, string? newValue, CompareInfo? ci, C
986986
//
987987
public string Replace(char oldChar, char newChar)
988988
{
989-
int firstIndex;
990-
if (oldChar == newChar || (firstIndex = IndexOf(oldChar)) < 0)
991-
{
989+
if (oldChar == newChar)
990+
return this;
991+
992+
int firstIndex = IndexOf(oldChar);
993+
994+
if (firstIndex < 0)
992995
return this;
993-
}
994996

995997
int remainingLength = Length - firstIndex;
996998
string result = FastAllocateString(Length);

0 commit comments

Comments
 (0)