diff options
-rw-r--r-- | src/System.Private.CoreLib/shared/System/Boolean.cs | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/src/System.Private.CoreLib/shared/System/Boolean.cs b/src/System.Private.CoreLib/shared/System/Boolean.cs index 7ec9227f1b..4daf6f3f96 100644 --- a/src/System.Private.CoreLib/shared/System/Boolean.cs +++ b/src/System.Private.CoreLib/shared/System/Boolean.cs @@ -97,18 +97,34 @@ namespace System public bool TryFormat(Span<char> destination, out int charsWritten) { - string s = m_value ? TrueLiteral : FalseLiteral; - - if (s.AsSpan().TryCopyTo(destination)) + if (m_value) { - charsWritten = s.Length; - return true; + if ((uint)destination.Length > 3) // uint cast, per https://github.com/dotnet/coreclr/issues/18688 + { + destination[0] = 'T'; + destination[1] = 'r'; + destination[2] = 'u'; + destination[3] = 'e'; + charsWritten = 4; + return true; + } } else { - charsWritten = 0; - return false; + if ((uint)destination.Length > 4) + { + destination[0] = 'F'; + destination[1] = 'a'; + destination[2] = 'l'; + destination[3] = 's'; + destination[4] = 'e'; + charsWritten = 5; + return true; + } } + + charsWritten = 0; + return false; } // Determines whether two Boolean objects are equal. |