Speeds up world loading (#315)

- [X] Speeds up world loading
- [X] Removes PeekChar cause it wasn't used
- [X] Adds a BufferReader
- [X] Removes BinaryFileReader
- [X] Removes reading/writing `char` since it is not consistent and will cause a deserialize issue if used.

Bumps version release
This commit is contained in:
Kamron Batman 2020-11-16 21:58:58 -08:00 • committed by GitHub
parent eb1c03c38b
commit 313eda6a3e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 175 additions and 91 deletions

View file

@ -32,8 +32,6 @@ namespace Server
protected long Index { get; set; }
private readonly char[] m_SingleCharBuffer = new char[1];
private byte[] m_CharacterBuffer;
private int m_MaxBufferChars;
@ -190,7 +188,7 @@ namespace Server
{
var bits = decimal.GetBits(value);
for (var i = 0; i < bits.Length; ++i)
for (var i = 0; i < 4; ++i)
{
Write(bits[i]);
}
@ -314,19 +312,6 @@ namespace Server
Index += 4;
}
public void Write(char value)
{
if (Index + 8 > Buffer.Length)
{
Flush();
}
m_SingleCharBuffer[0] = value;
var byteCount = m_Encoding.GetBytes(m_SingleCharBuffer, 0, 1, Buffer, (int)Index);
Index += byteCount;
}
public void Write(byte value)
{
if (Index + 1 > Buffer.Length)
@ -769,7 +754,7 @@ namespace Server
while (charsLeft > 0)
{
var charCount = charsLeft > m_MaxBufferChars ? m_MaxBufferChars : charsLeft;
var charCount = Math.Min(charsLeft, m_MaxBufferChars);
var byteLength = m_Encoding.GetBytes(value, current, charCount, m_CharacterBuffer, 0);
if (Index + byteLength > Buffer.Length)