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:
@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
class Demolish : Enter
|
||||
{
|
||||
readonly Actor target;
|
||||
readonly IEnumerable<IDemolishable> demolishables;
|
||||
readonly IDemolishable[] demolishables;
|
||||
readonly int delay;
|
||||
readonly int flashes;
|
||||
readonly int flashesDelay;
|
||||
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
: base(self, target)
|
||||
{
|
||||
this.target = target;
|
||||
demolishables = target.TraitsImplementing<IDemolishable>();
|
||||
demolishables = target.TraitsImplementing<IDemolishable>().ToArray();
|
||||
this.delay = delay;
|
||||
this.flashes = flashes;
|
||||
this.flashesDelay = flashesDelay;
|
||||
|
||||
Reference in New Issue
Block a user