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:
@@ -167,10 +167,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Facing = legacyFacing,
|
||||
|
||||
DamageModifiers = self.TraitsImplementing<IFirepowerModifier>()
|
||||
.Select(a => a.GetFirepowerModifier()),
|
||||
.Select(a => a.GetFirepowerModifier()).ToArray(),
|
||||
|
||||
InaccuracyModifiers = self.TraitsImplementing<IInaccuracyModifier>()
|
||||
.Select(a => a.GetInaccuracyModifier()),
|
||||
.Select(a => a.GetInaccuracyModifier()).ToArray(),
|
||||
|
||||
Source = muzzlePosition,
|
||||
SourceActor = self,
|
||||
|
||||
Reference in New Issue
Block a user