TechTree.GatherOwnedPrerequisites performance improvements.
- Consuming methods cared only about the count and not the actual actors, so only counts the actors rather that creating lists. - ProvidesPrerequisites implementations return cached objects rather then allocating new enumerables on each call.
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
@@ -38,11 +39,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
readonly ProvidesTechPrerequisiteInfo info;
|
||||
readonly bool enabled;
|
||||
|
||||
static readonly string[] NoPrerequisites = Array.Empty<string>();
|
||||
|
||||
public string Name => info.Name;
|
||||
|
||||
public IEnumerable<string> ProvidesPrerequisites => enabled ? info.Prerequisites : NoPrerequisites;
|
||||
public IEnumerable<string> ProvidesPrerequisites => enabled ? info.Prerequisites : Enumerable.Empty<string>();
|
||||
|
||||
public ProvidesTechPrerequisite(ProvidesTechPrerequisiteInfo info, ActorInitializer init)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user