From f4a8a1294ee7dc411dfb94275e5b6e6ba521aa1f Mon Sep 17 00:00:00 2001 From: DJWarmonger Date: Sun, 16 Dec 2018 15:46:48 +0100 Subject: [PATCH] Optimizations based on MSVS profiler. --- AI/VCAI/FuzzyHelper.cpp | 4 ++-- AI/VCAI/Pathfinding/AINodeStorage.cpp | 1 + lib/CPathfinder.cpp | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/AI/VCAI/FuzzyHelper.cpp b/AI/VCAI/FuzzyHelper.cpp index d1a81f2d6..82a0ae1fd 100644 --- a/AI/VCAI/FuzzyHelper.cpp +++ b/AI/VCAI/FuzzyHelper.cpp @@ -47,12 +47,12 @@ Goals::TSubgoal FuzzyHelper::chooseSolution(Goals::TGoalVec vec) for(auto goal : vec) { - logAi->debug("FuzzyHelper evaluated goal %s, priority=%i", goal->name(), goal->priority); + logAi->trace("FuzzyHelper evaluated goal %s, priority=%.4f", goal->name(), goal->priority); } Goals::TSubgoal result = *boost::max_element(vec, compareGoals); - logAi->debug("FuzzyHelper returned goal %s, priority=%i", result->name(), result->priority); + logAi->debug("FuzzyHelper returned goal %s, priority=%.4f", result->name(), result->priority); return result; } diff --git a/AI/VCAI/Pathfinding/AINodeStorage.cpp b/AI/VCAI/Pathfinding/AINodeStorage.cpp index c23820841..9fb3a0369 100644 --- a/AI/VCAI/Pathfinding/AINodeStorage.cpp +++ b/AI/VCAI/Pathfinding/AINodeStorage.cpp @@ -106,6 +106,7 @@ std::vector AINodeStorage::calculateNeighbours( const CPathfinderHelper * pathfinderHelper) { std::vector neighbours; + neighbours.reserve(16); const AIPathNode * srcNode = getAINode(source.node); auto accessibleNeighbourTiles = pathfinderHelper->getNeighbourTiles(source); diff --git a/lib/CPathfinder.cpp b/lib/CPathfinder.cpp index d21fa8621..d3a16e166 100644 --- a/lib/CPathfinder.cpp +++ b/lib/CPathfinder.cpp @@ -31,6 +31,7 @@ std::vector NodeStorage::calculateNeighbours( const CPathfinderHelper * pathfinderHelper) { std::vector neighbours; + neighbours.reserve(16); auto accessibleNeighbourTiles = pathfinderHelper->getNeighbourTiles(source); for(auto & neighbour : accessibleNeighbourTiles) @@ -70,6 +71,7 @@ std::vector NodeStorage::calculateTeleportations( std::vector CPathfinderHelper::getNeighbourTiles(const PathNodeInfo & source) const { std::vector neighbourTiles; + neighbourTiles.reserve(16); getNeighbours( *source.tile,