Reduce duplication and allocations around CalculateFrameIndices.

This commit is contained in:
Paul Chote
2023-03-08 23:18:57 +00:00
committed by Gustas
parent f0cf728825
commit 3b0b15abb9
3 changed files with 21 additions and 34 deletions

View File

@@ -43,15 +43,7 @@ namespace OpenRA.Mods.Common.Graphics
var tilesetNode = node.Value.Nodes.FirstOrDefault(n => n.Key == tileset);
if (tilesetNode != null)
{
// Only request the subset of frames that we actually need
int[] loadFrames = null;
if (length != null)
{
loadFrames = CalculateFrameIndices(start, length.Value, stride ?? length.Value, facings, frames, transpose, reverseFacings);
if (shadowStart >= 0)
loadFrames = loadFrames.Concat(loadFrames.Select(i => i + shadowStart - start)).ToArray();
}
var loadFrames = CalculateFrameIndices(start, length, stride ?? length ?? 0, facings, frames, transpose, reverseFacings, shadowStart);
return new[] { new ReservationInfo(tilesetNode.Value.Value, loadFrames, frames, tilesetNode.Location) };
}
}