Speedup MTGAllCards::countByType a bit

This commit is contained in:
Tobias Loose
2013-11-23 13:00:03 +01:00
parent 9ee44ca091
commit 6f083389c2
+3 -1
View File
@@ -544,12 +544,14 @@ int MTGAllCards::countBySet(int setId)
//TODO more efficient way ? //TODO more efficient way ?
int MTGAllCards::countByType(const string &_type) int MTGAllCards::countByType(const string &_type)
{ {
int type_id = findType(_type);
int result = 0; int result = 0;
map<int, MTGCard *>::iterator it; map<int, MTGCard *>::iterator it;
for (it = collection.begin(); it != collection.end(); it++) for (it = collection.begin(); it != collection.end(); it++)
{ {
MTGCard * c = it->second; MTGCard * c = it->second;
if (c->data->hasType(_type)) if (c->data->hasType(type_id))
{ {
result++; result++;
} }