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:
@@ -59,12 +59,12 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
[ScriptPropertyGroup("Power")]
|
||||
public class ActorPowerProperties : ScriptActorProperties, Requires<PowerInfo>
|
||||
{
|
||||
readonly IEnumerable<PowerTrait> power;
|
||||
readonly PowerTrait[] power;
|
||||
|
||||
public ActorPowerProperties(ScriptContext context, Actor self)
|
||||
: base(context, self)
|
||||
{
|
||||
power = self.TraitsImplementing<PowerTrait>();
|
||||
power = self.TraitsImplementing<PowerTrait>().ToArray();
|
||||
}
|
||||
|
||||
[Desc("Returns the power drained/provided by this actor.")]
|
||||
|
||||
Reference in New Issue
Block a user