diff --git a/src/libraries/System.Private.CoreLib/src/System/String.cs b/src/libraries/System.Private.CoreLib/src/System/String.cs index 7ca88a4b29c79..76048da7b75c2 100644 --- a/src/libraries/System.Private.CoreLib/src/System/String.cs +++ b/src/libraries/System.Private.CoreLib/src/System/String.cs @@ -321,35 +321,9 @@ string Ctor(char c, int count) } string result = FastAllocateString(count); - - if (c != '\0') // Fast path null char string + if (c != '\0') { - unsafe - { - fixed (char* dest = &result._firstChar) - { - uint cc = (uint)((c << 16) | c); - uint* dmem = (uint*)dest; - if (count >= 4) - { - count -= 4; - do - { - dmem[0] = cc; - dmem[1] = cc; - dmem += 2; - count -= 4; - } while (count >= 0); - } - if ((count & 2) != 0) - { - *dmem = cc; - dmem++; - } - if ((count & 1) != 0) - ((char*)dmem)[0] = c; - } - } + SpanHelpers.Fill(ref result._firstChar, (uint)count, c); } return result; }