Use for loops instead of foreach loops to minimize GC

pull/767/head
Andrew Cassidy 5 years ago
parent 2a43d6d6b3
commit 516e0829a5
No known key found for this signature in database
GPG Key ID: 963017B38FD477A1

@ -150,10 +150,10 @@ namespace Restock
_propertyBlock.SetColor(_shaderBlackbodyID, Color.black); _propertyBlock.SetColor(_shaderBlackbodyID, Color.black);
} }
foreach (var r in renderers) for (var i = 0; i < renderers.Count; i++)
{ {
r.SetPropertyBlock(_propertyBlock); renderers[i].SetPropertyBlock(_propertyBlock);
} }
} }
} }

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

@ -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);
} }

Loading…
Cancel
Save