Avoid boxing in TextWriter.Write(StringBuilder) (#24664)
authorAndrew Arnott <andrewarnott@gmail.com>
Mon, 20 May 2019 18:25:00 +0000 (12:25 -0600)
committerJan Kotas <jkotas@microsoft.com>
Mon, 20 May 2019 18:24:59 +0000 (11:24 -0700)
Fixes #24663 by calling `Write(ReadOnlySpan<char>)` instead of `Write(object)` with a boxed `Memory<char>`.

src/System.Private.CoreLib/shared/System/IO/TextWriter.cs

index 875eb59..890c35e 100644 (file)
@@ -305,7 +305,7 @@ namespace System.IO
             if (value != null)
             {
                 foreach (ReadOnlyMemory<char> chunk in value.GetChunks())
-                    Write(chunk);
+                    Write(chunk.Span);
             }
         }