From 2a8044e2a2f1d79c11771b127cc1bcf4d0c3fb24 Mon Sep 17 00:00:00 2001 From: Miepee Date: Sat, 28 Oct 2023 12:02:26 +0200 Subject: [PATCH] *Slightly* optimize memory usage --- YAMS-LIB/Program.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/YAMS-LIB/Program.cs b/YAMS-LIB/Program.cs index 09fd90b..ccc0b08 100644 --- a/YAMS-LIB/Program.cs +++ b/YAMS-LIB/Program.cs @@ -49,6 +49,7 @@ public static void Main(string am2rPath, string outputAm2rPath, string jsonPath) { gmData = UndertaleIO.Read(fs); } + Console.WriteLine("Read data file."); var decompileContext = new GlobalDecompileContext(gmData, false); // Check for 1.5.5 before doing *anything* @@ -678,7 +679,7 @@ void AddAllSpritesFromDir(string dirPath) void RotateTextureAndSaveToTexturePage(int rotation, UndertaleTexturePageItem texture) { - var texturePage = Image.Load(texture.TexturePage.TextureData.TextureBlob); + using var texturePage = Image.Load(texture.TexturePage.TextureData.TextureBlob); texturePage.Mutate(im => im.Hue(rotation, new Rectangle(texture.SourceX, texture.SourceY, texture.SourceWidth, texture.SourceHeight))); using var ms = new MemoryStream(); @@ -2833,7 +2834,8 @@ void RotateTextureAndSaveToTexturePage(int rotation, UndertaleTexturePageItem te """); // speed booster blocks near a5 activation - foreach (var gameObject in gmData.Rooms.ByName("rm_a5c08").GameObjects.Where(o => o.ObjectDefinition.Name.Content == "oBlockSpeed")) + var a5c08 = gmData.Rooms.ByName("rm_a5c08"); + foreach (var gameObject in a5c08.GameObjects.Where(o => o.ObjectDefinition.Name.Content == "oBlockSpeed")) { // Y 32 is the top row of speed blocks if (gameObject.Y == 32)