refs #721 Trying the unaltered name first is slower

because in nearly all cases, it just leads to comparing the names twice.
This commit is contained in:
Mathew Sutcliffe
2016-08-11 16:19:44 +01:00
parent 15cf07c1c5
commit 67b36bbfcf

View File

@@ -135,9 +135,6 @@ namespace BlackMisc
bool CAirlineIcaoCode::isContainedInSimplifiedName(const QString &candidate) const
{
if (candidate.isEmpty() || !this->hasName()) { return false; }
// try unaltered name first (should be faster)
if (this->getName().contains(candidate, Qt::CaseInsensitive)) { return true; }
auto simplifiedName = makeRange(getName().begin(), getName().end()).findBy([](QChar c) { return c.isLetter(); });
auto it = std::search(simplifiedName.begin(), simplifiedName.end(), candidate.begin(), candidate.end(), [](QChar a, QChar b) { return a.toUpper() == b.toUpper(); });
return it != simplifiedName.end();