From 339db24b56ab7a6b49c074d222a372a9633e1b69 Mon Sep 17 00:00:00 2001 From: Zach H Date: Mon, 6 Jul 2015 11:33:46 -0400 Subject: [PATCH] efficency loop --- common/decklist.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/common/decklist.cpp b/common/decklist.cpp index 3c54449e2..478ffb282 100644 --- a/common/decklist.cpp +++ b/common/decklist.cpp @@ -727,7 +727,7 @@ void DeckList::updateDeckHash() { QStringList cardList; bool isValidDeckList = true; - static QSet hashZones, optionalZones; + QSet hashZones, optionalZones; hashZones << "main" << "side"; // Zones in deck to be included in hashing process optionalZones << "tokens"; // Optional zones in deck not included in hashing process @@ -737,17 +737,15 @@ void DeckList::updateDeckHash() InnerDecklistNode *node = dynamic_cast(root->at(i)); for (int j = 0; j < node->size(); j++) { - DecklistCardNode *card = dynamic_cast(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(node->at(j)); + for (int k = 0; k < card->getNumber(); ++k) cardList.append((node->getName() == "side" ? "SB:" : "") + card->getName().toLower()); - } - else if (!optionalZones.contains(node->getName())) // Not a valid zone -> cheater? - { - isValidDeckList = false; // Deck is invalid - } + } + else if (!optionalZones.contains(node->getName())) // Not a valid zone -> cheater? + { + isValidDeckList = false; // Deck is invalid } } }