Converted CardPrimitive's basicAbilities from a map<int, int> to a bitset. With 92 abilities, that means our base container for abilities is now 16 bytes in size (down from 28), and is a fixed size, whereas the map would grow by 8 bytes per added ability.

This commit is contained in:
wrenczes@gmail.com
2011-04-26 09:35:38 +00:00
parent 425e49e608
commit a73fd4e99f
10 changed files with 74 additions and 90 deletions

View File

@@ -208,13 +208,17 @@ MTGCardInstance * CardDescriptor::match(MTGCardInstance * card)
}
//Abilities
for (map<int, int>::const_iterator it = basicAbilities.begin(); it != basicAbilities.end(); ++it)
std::bitset<Constants::NB_BASIC_ABILITIES> set = basicAbilities & card->basicAbilities;
if (mode == CD_NOT)
{
int j = it->first;
if ((basicAbilities[j] == 1 && !card->basicAbilities[j]) || (basicAbilities[j] == -1 && card->basicAbilities[j]))
{
match = NULL;
}
if (set.any())
return NULL;
}
else
{
if (set != basicAbilities)
return NULL;
}
if ((tapped == -1 && card->isTapped()) || (tapped == 1 && !card->isTapped()))