Faster QString handling in aircraft ICAO code

This commit is contained in:
Klaus Basan
2018-08-26 19:37:03 +02:00
parent 54802e9ea9
commit fd751e66c2

View File

@@ -141,7 +141,11 @@ namespace BlackMisc
{ {
// 0..65 // 0..65
score += 50; // same designator score += 50; // same designator
CMatchingUtils::addLogDetailsToList(log, *this, QString("Same designator: %1").arg(score)); if (log)
{
static const QString s("Same designator: %1");
CMatchingUtils::addLogDetailsToList(log, *this, s.arg(score));
}
int scoreOld = score; int scoreOld = score;
if (this->getRank() == 0) { score += 15; } if (this->getRank() == 0) { score += 15; }
@@ -149,20 +153,23 @@ namespace BlackMisc
else if (this->getRank() < 10) { score += (10 - this->getRank()); } else if (this->getRank() < 10) { score += (10 - this->getRank()); }
if (score > scoreOld) if (score > scoreOld)
{ {
CMatchingUtils::addLogDetailsToList(log, *this, QString("Added rank: %1").arg(score)); static const QString s("Added rank: %1");
CMatchingUtils::addLogDetailsToList(log, *this, s.arg(score));
} }
} }
else else
{ {
if (this->hasFamily() && this->getFamily() == otherCode.getFamily()) if (this->hasFamily() && this->getFamily() == otherCode.getFamily())
{ {
static const QString s("Added family: %1");
score += 30; score += 30;
CMatchingUtils::addLogDetailsToList(log, *this, QString("Added family: %1").arg(score)); CMatchingUtils::addLogDetailsToList(log, *this, s.arg(score));
} }
else if (this->hasValidCombinedType() && otherCode.getCombinedType() == this->getCombinedType()) else if (this->hasValidCombinedType() && otherCode.getCombinedType() == this->getCombinedType())
{ {
static const QString s("Added combined code: %1");
score += 20; score += 20;
CMatchingUtils::addLogDetailsToList(log, *this, QString("Added combined code: %1").arg(score)); CMatchingUtils::addLogDetailsToList(log, *this, s.arg(score));
} }
else if (this->hasValidCombinedType()) else if (this->hasValidCombinedType())
{ {
@@ -178,12 +185,14 @@ namespace BlackMisc
{ {
if (this->matchesManufacturer(otherCode.getManufacturer())) if (this->matchesManufacturer(otherCode.getManufacturer()))
{ {
static const QString s("Matches manufacturer '%1': %2");
score += 10; score += 10;
CMatchingUtils::addLogDetailsToList(log, *this, QString("Matches manufacturer '%1': %2").arg(this->getManufacturer()).arg(score)); CMatchingUtils::addLogDetailsToList(log, *this, s.arg(this->getManufacturer()).arg(score));
} }
else if (this->getManufacturer().contains(otherCode.getManufacturer(), Qt::CaseInsensitive)) else if (this->getManufacturer().contains(otherCode.getManufacturer(), Qt::CaseInsensitive))
{ {
CMatchingUtils::addLogDetailsToList(log, *this, QString("Contains manufacturer '%1': %2").arg(this->getManufacturer()).arg(score)); static const QString s("Contains manufacturer '%1': %2");
CMatchingUtils::addLogDetailsToList(log, *this, s.arg(this->getManufacturer()).arg(score));
score += 5; score += 5;
} }
} }
@@ -191,8 +200,9 @@ namespace BlackMisc
// 0..75 so far // 0..75 so far
if (this->isMilitary() == otherCode.isMilitary()) if (this->isMilitary() == otherCode.isMilitary())
{ {
static const QString s("Matches military flag '%1': %2");
score += 10; score += 10;
CMatchingUtils::addLogDetailsToList(log, *this, QString("Matches military flag '%1': %2").arg(boolToYesNo(this->isMilitary())).arg(score)); CMatchingUtils::addLogDetailsToList(log, *this, s.arg(boolToYesNo(this->isMilitary())).arg(score));
} }
// 0..85 // 0..85
return score; return score;
@@ -388,9 +398,8 @@ namespace BlackMisc
QString CAircraftIcaoCode::getDesignatorManufacturer() const QString CAircraftIcaoCode::getDesignatorManufacturer() const
{ {
QString d(getDesignator()); return (this->hasDesignator() ? this->getDesignator() : QStringLiteral("????")) %
if (this->hasManufacturer()) { d = d.append(" ").append(this->getManufacturer());} (this->hasManufacturer() ? (QStringLiteral(" ") % this->getManufacturer()) : QStringLiteral(""));
return d.trimmed();
} }
bool CAircraftIcaoCode::hasManufacturer() const bool CAircraftIcaoCode::hasManufacturer() const