Some very minimal code optimization.

lua-bytecode
Icedream 2014-12-11 03:41:32 +01:00
parent d7661343bb
commit 8c57d7befb
2 changed files with 5 additions and 4 deletions

View File

@ -184,8 +184,9 @@ namespace GarrysMod.AddonCreator.Addon
// long-compatible file reading // long-compatible file reading
for (long i = 0; i < fileSize; i += int.MaxValue) for (long i = 0; i < fileSize; i += int.MaxValue)
{ {
var tempContent = sr.ReadBytes((int) Math.Min(int.MaxValue, fileSize)); sr
tempContent.CopyTo(fileContent, i); .ReadBytes((int) Math.Min(int.MaxValue, fileSize))
.CopyTo(fileContent, i);
} }
// CRC check for this file // CRC check for this file

View File

@ -12,7 +12,7 @@ namespace GarrysMod.AddonCreator.Addon
/// </summary> /// </summary>
public virtual long Size 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; }
} }
/// <summary> /// <summary>
@ -20,7 +20,7 @@ namespace GarrysMod.AddonCreator.Addon
/// </summary> /// </summary>
public virtual int Crc32Hash 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; }
} }
/// <summary> /// <summary>