Pārlūkot izejas kodu

Use tuple instead of vector for comparing values

There are only 3 values, and they're only used for doing a comparison,
so it's wasteful to create a whole vector for that. std::tuple is better
suited for this use case.
Agoston Szepessy 3 gadi atpakaļ
vecāks
revīzija
0718acdb6d
1 mainītis faili ar 2 papildinājumiem un 3 dzēšanām
  1. 2 3
      lib/mapObjects/CGHeroInstance.cpp

+ 2 - 3
lib/mapObjects/CGHeroInstance.cpp

@@ -840,11 +840,10 @@ CStackBasicDescriptor CGHeroInstance::calculateNecromancy (const BattleResult &b
 				}
 				else
 				{
-					auto quality = [getCreatureID](std::shared_ptr<Bonus> pick) -> std::vector<int>
+					auto quality = [getCreatureID](std::shared_ptr<Bonus> pick) -> std::tuple<int, int, int>
 					{
 						const CCreature * c = VLC->creh->objects[getCreatureID(pick)];
-						std::vector<int> v = {c->level, static_cast<int>(c->cost.marketValue()), -pick->additionalInfo[1]};
-						return v;
+						return std::tuple<int, int, int> {c->level, static_cast<int>(c->cost.marketValue()), -pick->additionalInfo[1]};
 					};
 					if(quality(topPick) < quality(newPick))
 						topPick = newPick;