A new instance of UTF8Encoding used to be created every time
BinaryReader.ctor(Stream) was called, which created an instance of
UTF8Encoding that has no preamble. However, BinaryReader does not use
the preamble at all, so it doesn't matter if the encoding has a preamble
or not. Thus, the cached Encoding.UTF8 instance can be used (which has a
preamble).
private bool m_isMemoryStream; // "do we sit on MemoryStream?" for Read/ReadInt32 perf
private bool m_leaveOpen;
- public BinaryReader(Stream input) : this(input, new UTF8Encoding(), false) {
+ public BinaryReader(Stream input) : this(input, Encoding.UTF8, false) {
}
public BinaryReader(Stream input, Encoding encoding) : this(input, encoding, false) {