diff --git a/libcockatrice_deck_list/libcockatrice/deck_list/deck_list.cpp b/libcockatrice_deck_list/libcockatrice/deck_list/deck_list.cpp index 452133390..333be017b 100644 --- a/libcockatrice_deck_list/libcockatrice/deck_list/deck_list.cpp +++ b/libcockatrice_deck_list/libcockatrice/deck_list/deck_list.cpp @@ -656,15 +656,17 @@ static QString computeDeckHash(const DeckList &deckList) auto mainDeckNodes = deckList.getCardNodes({DECK_ZONE_MAIN}); auto sideDeckNodes = deckList.getCardNodes({DECK_ZONE_SIDE}); - QStringList cardList; - - static auto repeatName = [](const DecklistCardNode *node, const QString &prefix = {}) { - return (prefix + node->getName().toLower()).repeated(node->getNumber()); + static auto nodesToCardList = [](const QList &nodes, const QString &prefix = {}) { + QStringList result; + for (auto node : nodes) { + for (int i = 0; i < node->getNumber(); ++i) { + result.append(prefix + node->getName().toLower()); + } + } + return result; }; - std::transform(mainDeckNodes.cbegin(), mainDeckNodes.cend(), std::back_inserter(cardList), - [](auto node) { return repeatName(node); }); - std::transform(sideDeckNodes.cbegin(), sideDeckNodes.cend(), std::back_inserter(cardList), - [](auto node) { return repeatName(node, "SB:"); }); + + QStringList cardList = nodesToCardList(mainDeckNodes) + nodesToCardList(sideDeckNodes, "SB:"); cardList.sort(); QByteArray deckHashArray = QCryptographicHash::hash(cardList.join(";").toUtf8(), QCryptographicHash::Sha1);