diff --git a/src/libraries/System.Private.CoreLib/src/System/Boolean.cs b/src/libraries/System.Private.CoreLib/src/System/Boolean.cs index f8773d47ecf046..6869de20000279 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Boolean.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Boolean.cs @@ -96,22 +96,17 @@ public bool TryFormat(Span destination, out int charsWritten) { if (m_value) { - if (destination.Length >= 4) + if (TrueLiteral.TryCopyTo(destination)) { - ulong true_val = BitConverter.IsLittleEndian ? 0x65007500720054ul : 0x54007200750065ul; // "True" - Unsafe.WriteUnaligned(ref Unsafe.As(ref MemoryMarshal.GetReference(destination)), true_val); - charsWritten = 4; + charsWritten = TrueLiteral.Length; return true; } } else { - if (destination.Length >= 5) + if (FalseLiteral.TryCopyTo(destination)) { - ulong fals_val = BitConverter.IsLittleEndian ? 0x73006C00610046ul : 0x460061006C0073ul; // "Fals" - Unsafe.WriteUnaligned(ref Unsafe.As(ref MemoryMarshal.GetReference(destination)), fals_val); - destination[4] = 'e'; - charsWritten = 5; + charsWritten = FalseLiteral.Length; return true; } }