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:
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public readonly int MaxRadius = 4;
|
||||
|
||||
[Desc("The list of unit target types we are allowed to duplicate.")]
|
||||
public readonly HashSet<string> ValidTargets = new HashSet<string> { "Ground", "Water" };
|
||||
public readonly BitSet<TargetableType> ValidTargets = new BitSet<TargetableType>("Ground", "Water");
|
||||
|
||||
[Desc("Which factions this crate action can occur for.")]
|
||||
public readonly HashSet<string> ValidFactions = new HashSet<string>();
|
||||
|
||||
Reference in New Issue
Block a user