Avoid unnecessary delegate allocations
authorJustin Van Patten <jvp@justinvp.com>
Mon, 11 May 2015 07:03:34 +0000 (00:03 -0700)
committerJustin Van Patten <jvp@justinvp.com>
Sun, 24 May 2015 02:26:30 +0000 (19:26 -0700)
commitb0fb3fa764cd644594d452565f6e0f994e731b30
tree76edcbb4bf069cdfde62e9149b2e7788688ce9b2
parent300cc06e0c72ec3786216009efb7a7e9e9332031
Avoid unnecessary delegate allocations

There are 9 up-front delegate allocations (2 for TextReader and 7 for
TextWriter) that are unnecessary in most cases as most
TextReader/TextWriter subclasses override the base async methods where
such delegates are used. Instead, let the compiler allocate and cache
such delegates lazily, only in the rare cases when the delegates are
actually used.
src/mscorlib/src/System/IO/TextReader.cs
src/mscorlib/src/System/IO/TextWriter.cs