Tweaks for map generator performance.
The map generator is already performant, but we can remove a few rough edges from infrastructure it interacts with. - Add TypeDictionary constructor to clone from an existing copy. The map editor infrastructure relies heavily on cloning ActorReferences and the underlying dictionaries. A dedicated clone method avoids reflection overhead for CreateTypeContainer on a fresh instance. - Use ThrowIndexOutOfRangeException helper. This allows the Index method to be inlined. - Reuse lists in FloodFill. This avoids allocating and resizing new lists on each loop when we can reuse the existing capacity. - Manage CellEntryChanged at the layer rather than individual previews. We only need to attach/detach from the delegate once at the layer, rather than many times as previews are added and removed.
This commit is contained in:
committed by
Gustas Kažukauskas
parent
3ea5b08848
commit
a546ca2f92
@@ -82,13 +82,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
var td = new TypeDictionary();
|
||||
foreach (var init in inits)
|
||||
td.Add(init);
|
||||
|
||||
td.Add(new LocationInit(location.Value));
|
||||
td.Add(new CenterPositionInit(pos));
|
||||
td.Add(new FacingInit(initialFacing));
|
||||
var td = new TypeDictionary(inits)
|
||||
{
|
||||
new LocationInit(location.Value),
|
||||
new CenterPositionInit(pos),
|
||||
new FacingInit(initialFacing)
|
||||
};
|
||||
|
||||
var newUnit = self.World.CreateActor(producee.Name, td);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user