From a13c673d5faf35912995bb29533f5d8a76a0441f Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Wed, 20 Sep 2017 14:49:00 +1000 Subject: [PATCH] turns out GZipStream.ReadByte() allocates a 1 byte array each time, so avoid that --- ClassicalSharp/Map/Formats/MapLvl.Importer.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ClassicalSharp/Map/Formats/MapLvl.Importer.cs b/ClassicalSharp/Map/Formats/MapLvl.Importer.cs index c0dccc026..26b5917ec 100644 --- a/ClassicalSharp/Map/Formats/MapLvl.Importer.cs +++ b/ClassicalSharp/Map/Formats/MapLvl.Importer.cs @@ -48,12 +48,14 @@ namespace ClassicalSharp.Map { void ReadCustomBlocks(Stream s, int width, int height, int length, byte[] blocks) { byte[] chunk = new byte[16 * 16 * 16]; + byte[] data = new byte[1]; for (int y = 0; y < height; y += 16) for (int z = 0; z < length; z += 16) for (int x = 0; x < width; x += 16) { - if (s.ReadByte() != 1) continue; + int read = s.Read(data, 0, 1); + if (read == 0 || data[0] != 1) continue; s.Read(chunk, 0, chunk.Length); int baseIndex = (y * length + z) * width + x;