Skip to content
Merged
Prev Previous commit
Next Next commit
Don't use trick for collapsed epilogs
  • Loading branch information
gfoidl authored and github-actions committed Aug 17, 2022
commit 424f16bdb3fc3ce0e49adb25ee6b3dfe45883c33
Original file line number Diff line number Diff line change
Expand Up @@ -986,11 +986,13 @@ private string ReplaceCore(string oldValue, string? newValue, CompareInfo? ci, C
//
public string Replace(char oldChar, char newChar)
{
int firstIndex;
if (oldChar == newChar || (firstIndex = IndexOf(oldChar)) < 0)
{
if (oldChar == newChar)
return this;

int firstIndex = IndexOf(oldChar);

if (firstIndex < 0)
return this;
}

int remainingLength = Length - firstIndex;
string result = FastAllocateString(Length);
Expand Down