From 8c57d7befb43e5b4ad82d8edcdc48a9f507f659f Mon Sep 17 00:00:00 2001 From: icedream Date: Thu, 11 Dec 2014 03:41:32 +0100 Subject: [PATCH] Some very minimal code optimization. --- src/addoncreator/Addon/AddonFile.cs | 5 +++-- src/addoncreator/Addon/AddonFileInfo.cs | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/addoncreator/Addon/AddonFile.cs b/src/addoncreator/Addon/AddonFile.cs index 8bf5736..25474d0 100644 --- a/src/addoncreator/Addon/AddonFile.cs +++ b/src/addoncreator/Addon/AddonFile.cs @@ -184,8 +184,9 @@ namespace GarrysMod.AddonCreator.Addon // long-compatible file reading for (long i = 0; i < fileSize; i += int.MaxValue) { - var tempContent = sr.ReadBytes((int) Math.Min(int.MaxValue, fileSize)); - tempContent.CopyTo(fileContent, i); + sr + .ReadBytes((int) Math.Min(int.MaxValue, fileSize)) + .CopyTo(fileContent, i); } // CRC check for this file diff --git a/src/addoncreator/Addon/AddonFileInfo.cs b/src/addoncreator/Addon/AddonFileInfo.cs index 1354631..d14d26d 100644 --- a/src/addoncreator/Addon/AddonFileInfo.cs +++ b/src/addoncreator/Addon/AddonFileInfo.cs @@ -12,7 +12,7 @@ namespace GarrysMod.AddonCreator.Addon /// public virtual long Size { - get { return _size.HasValue ? _size.Value : (_size = GetContents().Length).Value; } + get { lock(this) return _size.HasValue ? _size.Value : (_size = GetContents().Length).Value; } } /// @@ -20,7 +20,7 @@ namespace GarrysMod.AddonCreator.Addon /// public virtual int Crc32Hash { - get { return _hash.HasValue ? _hash.Value : (_hash = Crc32.Compute(GetContents())).Value; } + get { lock (this) return _hash.HasValue ? _hash.Value : (_hash = Crc32.Compute(GetContents())).Value; } } ///