Use a BitSet for representing target types.
- Rename Bits<T> to BitSet<T>. - Implement set based helpers for BitSet<T>. - When representing TargetTypes of ITargetable in various traits, use a BitSet<TargetableType> instead of HashSet<string> for better performance & reduced memory usage. - Fix FieldLoader to trim input values when generating a BitSet<T>. - Require T in BitSet<T> and BitSetAllocator<T> to be a class since it's just a marker value. This allows the JIT to instantiate generic code for these classes once, as they don't benefit from specialized code for T. (Typically JITs will generate shared code for all reference types, and unique code for every value type encountered).
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Orders
|
||||
@@ -67,9 +68,9 @@ namespace OpenRA.Mods.Common.Orders
|
||||
|
||||
public class TargetTypeOrderTargeter : UnitOrderTargeter
|
||||
{
|
||||
readonly HashSet<string> targetTypes;
|
||||
readonly BitSet<TargetableType> targetTypes;
|
||||
|
||||
public TargetTypeOrderTargeter(HashSet<string> targetTypes, string order, int priority, string cursor, bool targetEnemyUnits, bool targetAllyUnits)
|
||||
public TargetTypeOrderTargeter(BitSet<TargetableType> targetTypes, string order, int priority, string cursor, bool targetEnemyUnits, bool targetAllyUnits)
|
||||
: base(order, priority, cursor, targetEnemyUnits, targetAllyUnits)
|
||||
{
|
||||
this.targetTypes = targetTypes;
|
||||
|
||||
Reference in New Issue
Block a user