efficency loop

This commit is contained in:
Zach H 2015-07-06 11:33:46 -04:00
parent 9e2da24629
commit 339db24b56

View file

@ -727,7 +727,7 @@ void DeckList::updateDeckHash()
{ {
QStringList cardList; QStringList cardList;
bool isValidDeckList = true; bool isValidDeckList = true;
static QSet<QString> hashZones, optionalZones; QSet<QString> hashZones, optionalZones;
hashZones << "main" << "side"; // Zones in deck to be included in hashing process hashZones << "main" << "side"; // Zones in deck to be included in hashing process
optionalZones << "tokens"; // Optional zones in deck not included in hashing process optionalZones << "tokens"; // Optional zones in deck not included in hashing process
@ -736,12 +736,11 @@ void DeckList::updateDeckHash()
{ {
InnerDecklistNode *node = dynamic_cast<InnerDecklistNode *>(root->at(i)); InnerDecklistNode *node = dynamic_cast<InnerDecklistNode *>(root->at(i));
for (int j = 0; j < node->size(); j++) for (int j = 0; j < node->size(); j++)
{
DecklistCardNode *card = dynamic_cast<DecklistCardNode *>(node->at(j));
for (int k = 0; k < card->getNumber(); ++k)
{ {
if (hashZones.contains(node->getName())) // Mainboard or Sideboard if (hashZones.contains(node->getName())) // Mainboard or Sideboard
{ {
DecklistCardNode *card = dynamic_cast<DecklistCardNode *>(node->at(j));
for (int k = 0; k < card->getNumber(); ++k)
cardList.append((node->getName() == "side" ? "SB:" : "") + card->getName().toLower()); cardList.append((node->getName() == "side" ? "SB:" : "") + card->getName().toLower());
} }
else if (!optionalZones.contains(node->getName())) // Not a valid zone -> cheater? else if (!optionalZones.contains(node->getName())) // Not a valid zone -> cheater?
@ -750,7 +749,6 @@ void DeckList::updateDeckHash()
} }
} }
} }
}
cardList.sort(); cardList.sort();
QByteArray deckHashArray = QCryptographicHash::hash(cardList.join(";").toUtf8(), QCryptographicHash::Sha1); QByteArray deckHashArray = QCryptographicHash::hash(cardList.join(";").toUtf8(), QCryptographicHash::Sha1);
quint64 number = (((quint64) (unsigned char) deckHashArray[0]) << 32) quint64 number = (((quint64) (unsigned char) deckHashArray[0]) << 32)