Commit caa08a51 authored by Volker Krause's avatar Volker Krause
Browse files

Switch airport database to the new name tokenizer and QStringView

This can still be done more efficiently, but here we usually only have
few tokens to process, so this isn't a priority for now, and it's certainly
more efficient than before.
parent 6202739e
......@@ -7,10 +7,10 @@
#include "airportdb.h"
#include "airportdb_p.h"
#include "airportdb_data.cpp"
#include "airportnametokenizer_p.h"
#include "stringutil.h"
#include <QDebug>
#include <QRegularExpression>
#include <QTimeZone>
#include <algorithm>
......@@ -196,15 +196,15 @@ static void iataCodeForNameFragments(const QStringList &fragments, std::vector<I
iataCodeForNonUniqueFragments(fragments, codes);
static QStringList splitToFragments(const QString &name)
static QStringList splitToFragments(QStringView name)
return name.split(QRegularExpression(QStringLiteral("[ 0-9/'\"\\(\\)&\\,.–„-]")),
AirportNameTokenizer tokenizer(name);
return tokenizer.toStringList();
std::vector<KnowledgeDb::IataCode> KnowledgeDb::iataCodesFromName(const QString &name)
std::vector<KnowledgeDb::IataCode> KnowledgeDb::iataCodesFromName(QStringView name)
const auto fragments = splitToFragments(name);
QStringList normalizedFragments;
......@@ -241,7 +241,7 @@ std::vector<KnowledgeDb::IataCode> KnowledgeDb::iataCodesFromName(const QString
return codes;
KnowledgeDb::IataCode KnowledgeDb::iataCodeFromName(const QString &name)
KnowledgeDb::IataCode KnowledgeDb::iataCodeFromName(QStringView name)
const auto fragments = splitToFragments(name);
QStringList normalizedFragments;
......@@ -37,9 +37,9 @@ KITINERARY_EXPORT QTimeZone timezoneForAirport(IataCode iataCode);
KITINERARY_EXPORT CountryId countryForAirport(IataCode iataCode);
/** Attempts to find the unique IATA code for the given airport name. */
KITINERARY_EXPORT IataCode iataCodeFromName(const QString &name);
KITINERARY_EXPORT IataCode iataCodeFromName(QStringView name);
/** Returns all possible IATA code candidates for the given airport name. */
KITINERARY_EXPORT std::vector<IataCode> iataCodesFromName(const QString &name);
KITINERARY_EXPORT std::vector<IataCode> iataCodesFromName(QStringView name);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment