1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-02-03 13:01:33 +02:00

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.
This commit is contained in:
Agoston Szepessy 2022-09-24 23:50:31 -07:00
parent 4205701f96
commit 0718acdb6d

View File

@ -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;