[Mono.Profiler.Log] Fix excessive byte array allocations.
authorAlex Rønne Petersen <alpeters@microsoft.com>
Tue, 19 Sep 2017 18:32:26 +0000 (20:32 +0200)
committerAlex Rønne Petersen <alpeters@microsoft.com>
Wed, 20 Sep 2017 12:17:26 +0000 (14:17 +0200)
commitdcbbe94d4e9c0cab8848946797a916f4ae0bdc1d
tree8a452be12813fabdd36c0e3d5c788f98e9d6dbfe
parentef2f4f2de28bc4db350ff4cff0d1488babaf2db2
[Mono.Profiler.Log] Fix excessive byte array allocations.

The problem was that the base Stream.ReadByte () method allocates a temporary
byte array and then calls Read (..., 1) on it. To solve this, we override
ReadByte () in LogStream and use a private buffer to hold the result.

It's a bit of a mystery to me why Stream.ReadByte () does it this way. The
documentation for Stream explicitly says that instance methods aren't thread
safe, so it would be perfectly fine for Stream.ReadByte () to do what we do
here...
mcs/class/Mono.Profiler.Log/Mono.Profiler.Log/LogStream.cs