diff options
author | Mike FABIAN <mike.fabian@basyskom.de> | 2010-09-07 18:55:18 +0200 |
---|---|---|
committer | Mike FABIAN <mike.fabian@basyskom.de> | 2010-09-08 10:51:12 +0200 |
commit | f61f235b1104d26a266a8f9fdcc286fff1e50ea4 (patch) | |
tree | 70f177dcb391aad872ec565cb0eb6980bed4ed95 | |
parent | 995b69ad8ead6e2c4b8bcdf44ecc6fa621d82891 (diff) |
Changes: speedup MLocationDatabase::matchingCities()
RevBy: TrustMe
Details:
before:
RESULT : Pt_MLocationDatabase::benchmarkMatchingCities():
0.21 msecs per iteration (total: 56, iterations: 256)
after:
RESULT : Pt_MLocationDatabase::benchmarkMatchingCities():
0.12 msecs per iteration (total: 64, iterations: 512)
-rw-r--r-- | src/corelib/i18n/mlocationdatabase.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/corelib/i18n/mlocationdatabase.cpp b/src/corelib/i18n/mlocationdatabase.cpp index b642d7ef..26f977c1 100644 --- a/src/corelib/i18n/mlocationdatabase.cpp +++ b/src/corelib/i18n/mlocationdatabase.cpp @@ -21,6 +21,7 @@ #include <QFile> #include <QDomDocument> +#include <QStringMatcher> #include <QDebug> const QString path = "/usr/share/meegotouch/locationdatabase/"; @@ -255,9 +256,10 @@ QList<MCity> MLocationDatabase::matchingCities(const QString& searchString) Q_D(MLocationDatabase); QList<MCity> list; + QStringMatcher matcher(searchString, Qt::CaseInsensitive); foreach (const MCity &city, d->cities) { - if (city.englishName().contains(searchString, Qt::CaseInsensitive) - || city.localName().contains(searchString, Qt::CaseInsensitive)) + if (matcher.indexIn(city.englishName()) != -1 + || matcher.indexIn(city.localName()) != -1) { list.append( city ); } |