Rework PriorityQueue for performance.

- Providing the comparer as a type argument that is a struct allows the calls to be devirtualised, leading to approx a 3x performance improvement.
- Use a single backing array, rather than a list of arrays.
This commit is contained in:
RoosterDragon
2023-03-22 18:04:14 +00:00
committed by abcdefg30
parent 7a4ac01348
commit 8a4303cc94
4 changed files with 90 additions and 49 deletions

View File

@@ -170,7 +170,7 @@ namespace OpenRA.Mods.Common.Pathfinder
this.heuristicWeightPercentage = heuristicWeightPercentage;
TargetPredicate = targetPredicate;
this.recorder = recorder;
openQueue = new PriorityQueue<GraphConnection>(GraphConnection.ConnectionCostComparer);
openQueue = new Primitives.PriorityQueue<GraphConnection, GraphConnection.CostComparer>(default);
}
void AddInitialCell(CPos location, Func<CPos, int> customCost)