Cache results of TraitsImplementing calls.
If a class is caching the TraitsImplementing enumerable, instead cache the results of enumerating it to an array. The avoids having to enumerate the sequence each time it is needed.
This commit is contained in:
@@ -17,12 +17,12 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
public class Turn : Activity
|
||||
{
|
||||
readonly IEnumerable<IDisableMove> moveDisablers;
|
||||
readonly IDisableMove[] moveDisablers;
|
||||
readonly int desiredFacing;
|
||||
|
||||
public Turn(Actor self, int desiredFacing)
|
||||
{
|
||||
moveDisablers = self.TraitsImplementing<IDisableMove>();
|
||||
moveDisablers = self.TraitsImplementing<IDisableMove>().ToArray();
|
||||
this.desiredFacing = desiredFacing;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user