Use for loops instead of foreach loops to minimize GC

This commit is contained in:
Andrew Cassidy 2019-08-31 11:28:37 -07:00
parent 2a43d6d6b3
commit 516e0829a5
No known key found for this signature in database
GPG Key ID: 963017B38FD477A1
4 changed files with 11 additions and 9 deletions

View File

@ -151,9 +151,9 @@ namespace Restock
} }
foreach (var r in renderers) for (var i = 0; i < renderers.Count; i++)
{ {
r.SetPropertyBlock(_propertyBlock); renderers[i].SetPropertyBlock(_propertyBlock);
} }
} }
} }

View File

@ -314,9 +314,9 @@ namespace Restock
} }
} }
foreach (var m in _modules) for (var i = 0; i < _modules.Count; i++)
{ {
if (m.ModuleIsActive()) if (_modules[i].ModuleIsActive())
{ {
return true; return true;
} }

View File

@ -100,10 +100,12 @@ namespace Restock
texScale[pipeStretchIndex] = stretch; texScale[pipeStretchIndex] = stretch;
texOffset[pipeStretchIndex] = (1 - stretch) / 2; texOffset[pipeStretchIndex] = (1 - stretch) / 2;
foreach (var material in pipeMaterials) for (var i = 0; i < pipeMaterials.Length; i++)
{ {
foreach (var id in pipeMaterialIDs) var material = pipeMaterials[i];
for (var j = 0; j < pipeMaterialIDs.Length; j++)
{ {
var id = pipeMaterialIDs[j];
material.SetTextureScale(id, texScale); material.SetTextureScale(id, texScale);
material.SetTextureOffset(id, texOffset); material.SetTextureOffset(id, texOffset);
} }