From 6f083389c242d78acb2cc59b9f414a72b1609665 Mon Sep 17 00:00:00 2001 From: Tobias Loose Date: Sat, 23 Nov 2013 13:00:03 +0100 Subject: [PATCH] Speedup MTGAllCards::countByType a bit --- projects/mtg/src/MTGDeck.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/projects/mtg/src/MTGDeck.cpp b/projects/mtg/src/MTGDeck.cpp index 7359271b7..058c1d4c3 100644 --- a/projects/mtg/src/MTGDeck.cpp +++ b/projects/mtg/src/MTGDeck.cpp @@ -544,12 +544,14 @@ int MTGAllCards::countBySet(int setId) //TODO more efficient way ? int MTGAllCards::countByType(const string &_type) { + int type_id = findType(_type); + int result = 0; map::iterator it; for (it = collection.begin(); it != collection.end(); it++) { MTGCard * c = it->second; - if (c->data->hasType(_type)) + if (c->data->hasType(type_id)) { result++; }