Removed check

When searching for a card the line edit will not be empty, so this check
is not needed. The performance when the line edit IS empty will take a
slight hit, but you really want additional performance when searching,
not when the line edit is empty.

Removing will increase performance.
This commit is contained in:
Matt Lowe 2015-04-15 12:25:06 +02:00
parent 778ad8dee1
commit 2e5ecd841c

View file

@ -125,13 +125,13 @@ bool CardDatabaseDisplayModel::lessThan(const QModelIndex &left, const QModelInd
if (!cardName.isEmpty()) if (!cardName.isEmpty())
{ {
if (leftString.compare(cardName, Qt::CaseInsensitive) == 0) {// exact match should be at top // exact match should be at top
if (leftString.compare(cardName, Qt::CaseInsensitive) == 0)
return true; return true;
}
if (rightString.compare(cardName, Qt::CaseInsensitive) == 0) {// exact match should be at top // exact match should be at top
if (rightString.compare(cardName, Qt::CaseInsensitive) == 0)
return false; return false;
}
bool isLeftType2 = leftString.startsWith(cardName, Qt::CaseInsensitive); bool isLeftType2 = leftString.startsWith(cardName, Qt::CaseInsensitive);
bool isRightType2 = rightString.startsWith(cardName, Qt::CaseInsensitive); bool isRightType2 = rightString.startsWith(cardName, Qt::CaseInsensitive);
@ -141,7 +141,6 @@ bool CardDatabaseDisplayModel::lessThan(const QModelIndex &left, const QModelInd
return false; return false;
} }
return QString::localeAwareCompare(leftString, rightString) < 0; return QString::localeAwareCompare(leftString, rightString) < 0;
} }
bool CardDatabaseDisplayModel::filterAcceptsRow(int sourceRow, const QModelIndex & /*sourceParent*/) const bool CardDatabaseDisplayModel::filterAcceptsRow(int sourceRow, const QModelIndex & /*sourceParent*/) const
@ -151,13 +150,12 @@ bool CardDatabaseDisplayModel::filterAcceptsRow(int sourceRow, const QModelIndex
if (((isToken == ShowTrue) && !info->getIsToken()) || ((isToken == ShowFalse) && info->getIsToken())) if (((isToken == ShowTrue) && !info->getIsToken()) || ((isToken == ShowFalse) && info->getIsToken()))
return false; return false;
if (!cardName.isEmpty()) if (!CardInfo::simplifyName(info->getName()).contains(cardName, Qt::CaseInsensitive))
if (!CardInfo::simplifyName(info->getName()).contains(cardName, Qt::CaseInsensitive)) return false;
return false;
if (!cardNameSet.isEmpty()) if (!cardNameSet.isEmpty())
if (!cardNameSet.contains(info->getName())) if (!cardNameSet.contains(info->getName()))
return false; return false;
if (filterTree != NULL) if (filterTree != NULL)
return filterTree->acceptsCard(info); return filterTree->acceptsCard(info);