Avoid iterating twice in ReadData()

This commit is contained in:
ORelio 2020-05-24 14:47:11 +02:00
parent 06714423a3
commit 9eeb052bb7

View file

@ -36,9 +36,9 @@ namespace MinecraftClient.Protocol.Handlers
/// <returns>The data read from the cache as an array</returns>
public byte[] ReadData(int offset, Queue<byte> cache)
{
byte[] result = cache.Take(offset).ToArray();
byte[] result = new byte[offset];
for (int i = 0; i < offset; i++)
cache.Dequeue();
result[i] = cache.Dequeue();
return result;
}