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:
@@ -45,10 +45,13 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public override void Tick(Actor self)
|
||||
{
|
||||
isActive = self.World.ActorsWithTrait<Production>()
|
||||
.Any(x => x.Actor.Owner == self.Owner
|
||||
&& x.Trait.Info.Produces.Contains(Info.Type));
|
||||
|
||||
isActive = false;
|
||||
foreach (var x in self.World.ActorsWithTrait<Production>())
|
||||
if (x.Actor.Owner == self.Owner && x.Trait.Info.Produces.Contains(Info.Type))
|
||||
{
|
||||
isActive = true;
|
||||
break;
|
||||
}
|
||||
base.Tick(self);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user