From c641738821c0b4e3bdbe4f2d6869baab479ea986 Mon Sep 17 00:00:00 2001 From: morkt Date: Mon, 20 Apr 2015 14:08:59 +0400 Subject: [PATCH] (DatOpener.OpenEntry): get rid of the intermediate MemoryStream. --- ArcFormats/ArcGsPack.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ArcFormats/ArcGsPack.cs b/ArcFormats/ArcGsPack.cs index 0f561cf3..da19ef8f 100644 --- a/ArcFormats/ArcGsPack.cs +++ b/ArcFormats/ArcGsPack.cs @@ -156,13 +156,12 @@ namespace GameRes.Formats.Gs { if (0 == entry.Size) return Stream.Null; + var input = arc.File.CreateStream (entry.Offset, entry.Size); var packed_entry = entry as PackedEntry; if (null == packed_entry) - return arc.File.CreateStream (entry.Offset, entry.Size); - byte[] packed = new byte[packed_entry.Size]; - arc.File.View.Read (entry.Offset, packed, 0, entry.Size); - using (var stream = new MemoryStream (packed)) - using (var reader = new LzssReader (stream, packed.Length, (int)packed_entry.UnpackedSize)) + return input; + using (input) + using (var reader = new LzssReader (input, (int)packed_entry.Size, (int)packed_entry.UnpackedSize)) { reader.Unpack(); return new MemoryStream (reader.Data, false);