Browse Source

Optimizations based on MSVS profiler.

DJWarmonger 7 years ago
parent
commit
f4a8a1294e
3 changed files with 5 additions and 2 deletions
  1. 2 2
      AI/VCAI/FuzzyHelper.cpp
  2. 1 0
      AI/VCAI/Pathfinding/AINodeStorage.cpp
  3. 2 0
      lib/CPathfinder.cpp

+ 2 - 2
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;
 }

+ 1 - 0
AI/VCAI/Pathfinding/AINodeStorage.cpp

@@ -106,6 +106,7 @@ std::vector<CGPathNode *> AINodeStorage::calculateNeighbours(
 	const CPathfinderHelper * pathfinderHelper)
 {
 	std::vector<CGPathNode *> neighbours;
+	neighbours.reserve(16);
 	const AIPathNode * srcNode = getAINode(source.node);
 	auto accessibleNeighbourTiles = pathfinderHelper->getNeighbourTiles(source);
 

+ 2 - 0
lib/CPathfinder.cpp

@@ -31,6 +31,7 @@ std::vector<CGPathNode *> NodeStorage::calculateNeighbours(
 	const CPathfinderHelper * pathfinderHelper)
 {
 	std::vector<CGPathNode *> neighbours;
+	neighbours.reserve(16);
 	auto accessibleNeighbourTiles = pathfinderHelper->getNeighbourTiles(source);
 
 	for(auto & neighbour : accessibleNeighbourTiles)
@@ -70,6 +71,7 @@ std::vector<CGPathNode *> NodeStorage::calculateTeleportations(
 std::vector<int3> CPathfinderHelper::getNeighbourTiles(const PathNodeInfo & source) const
 {
 	std::vector<int3> neighbourTiles;
+	neighbourTiles.reserve(16);
 
 	getNeighbours(
 		*source.tile,