From ba66d2d3c125136171dc9fec34bb9d424a6a731d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 2 Apr 2019 10:13:26 +0100 Subject: minor cleanup on mesh decompress code --- .../PhysicsModules/Meshing/Meshmerizer/Meshmerizer.cs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/Meshmerizer.cs') diff --git a/OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/Meshmerizer.cs b/OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/Meshmerizer.cs index 0d4b6b9..de39d0e 100644 --- a/OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/Meshmerizer.cs +++ b/OpenSim/Region/PhysicsModules/Meshing/Meshmerizer/Meshmerizer.cs @@ -597,28 +597,22 @@ namespace OpenSim.Region.PhysicsModule.Meshing { OSD decodedOsd = null; - using (MemoryStream inMs = new MemoryStream(meshBytes)) + using (MemoryStream outMs = new MemoryStream()) { - using (MemoryStream outMs = new MemoryStream()) + using (MemoryStream inMs = new MemoryStream(meshBytes)) { using (DeflateStream decompressionStream = new DeflateStream(inMs, CompressionMode.Decompress)) { - byte[] readBuffer = new byte[2048]; + byte[] readBuffer = new byte[8192]; inMs.Read(readBuffer, 0, 2); // skip first 2 bytes in header int readLen = 0; while ((readLen = decompressionStream.Read(readBuffer, 0, readBuffer.Length)) > 0) outMs.Write(readBuffer, 0, readLen); - - outMs.Flush(); - - outMs.Seek(0, SeekOrigin.Begin); - - byte[] decompressedBuf = outMs.GetBuffer(); - - decodedOsd = OSDParser.DeserializeLLSDBinary(decompressedBuf); } } + outMs.Seek(0, SeekOrigin.Begin); + decodedOsd = OSDParser.DeserializeLLSDBinary(outMs); } return decodedOsd; } -- cgit v1.1