Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Jeremy Koritzinsky <[email protected]>
  • Loading branch information
adamsitnik and jkoritzinsky authored Nov 15, 2021
commit a05de4b2a4d26b671a07e83a3e73d519926b155b
10 changes: 6 additions & 4 deletions src/libraries/System.Private.CoreLib/src/System/String.cs
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,12 @@ string Ctor(char c, int count)
throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NegativeCount);
}

char[] arr = new char[count];
Span<char> s = new(arr);
s.Fill(c);
return new(s);
string result = FastAllocateString(count);
if (c != '\0')
{
MemoryMarshal.CreateSpan(ref result._firstChar, count).Fill(c);
}
return result;
}

[MethodImpl(MethodImplOptions.InternalCall)]
Expand Down