Tackle the last of the low hanging fruit for memory allocations in the main game loop.
- Avoid calling string.Split twice in SprintFont.Measure. - Change ActorsInBox method of ActorMap and ScreenMap to avoid allocating and intermediate list. As a bonus this allows the sequence to be lazily consumed. Also avoid LINQ in these methods. - In FrozenUnderFog.TickRender, the method exits early if no players are visible so the attempt at lazy generation was not needed. - Unwrap a LINQ Any call in ClassicProductionQueue.Tick. - Merge some successive Where calls in ProximityCapturable into single predicates.
This commit is contained in:
@@ -111,18 +111,13 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public void TickRender(WorldRenderer wr, Actor self)
|
||||
{
|
||||
if (self.Destroyed || !initialized || !visible.Any(v => v.Value))
|
||||
if (self.Destroyed || !initialized || !visible.Values.Any(v => v))
|
||||
return;
|
||||
|
||||
IRenderable[] renderables = null;
|
||||
var renderables = self.Render(wr).ToArray();
|
||||
foreach (var player in self.World.Players)
|
||||
if (visible[player])
|
||||
{
|
||||
// Lazily generate a copy of the underlying data.
|
||||
if (renderables == null)
|
||||
renderables = self.Render(wr).ToArray();
|
||||
frozen[player].Renderables = renderables;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<IRenderable> ModifyRender(Actor self, WorldRenderer wr, IEnumerable<IRenderable> r)
|
||||
|
||||
Reference in New Issue
Block a user