aboutsummaryrefslogtreecommitdiffstats
path: root/src/controls
diff options
context:
space:
mode:
authorAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-03-28 18:39:46 +0300
committerAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-03-29 08:53:13 +0000
commit7edb11888b27825baf92b292b946d0148bd353db (patch)
treea60402f715d074b6616172edb7df70eaf9dbc948 /src/controls
parent73ca0cff27aac15fd7e8eff0ed51657aed6a0da1 (diff)
QQuickStyleSelector: optimize string usage
De-duplicate calls and cache results. Change-Id: Ia3424ac5149b947530e724b07adbff95cb54faf7 Reviewed-by: Liang Qi <liang.qi@theqtcompany.com>
Diffstat (limited to 'src/controls')
-rw-r--r--src/controls/qquickstyleselector.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/controls/qquickstyleselector.cpp b/src/controls/qquickstyleselector.cpp
index 9a48a9a4..64e9d500 100644
--- a/src/controls/qquickstyleselector.cpp
+++ b/src/controls/qquickstyleselector.cpp
@@ -121,9 +121,10 @@ static QString selectionHelper(const QString &path, const QString &fileName, con
// If we reach here there were no successful files found at a lower level in this branch, so we
// should check this level as a potential result.
- if (!QFileInfo::exists(path + fileName))
+ const QString result = path + fileName;
+ if (!QFileInfo::exists(result))
return QString();
- return path + fileName;
+ return result;
}
QString QQuickStyleSelectorPrivate::select(const QString &filePath) const
@@ -133,8 +134,9 @@ QString QQuickStyleSelectorPrivate::select(const QString &filePath) const
if (!fi.exists())
return filePath;
- QString ret = selectionHelper(fi.path().isEmpty() ? QString() : fi.path() + QLatin1Char('/'),
- fi.fileName(), allSelectors(true));
+ const QString path = fi.path();
+ const QString ret = selectionHelper(path.isEmpty() ? QString() : path + QLatin1Char('/'),
+ fi.fileName(), allSelectors(true));
if (!ret.isEmpty())
return ret;
@@ -178,14 +180,12 @@ QString QQuickStyleSelector::select(const QString &fileName) const
}
QUrl url(d->baseUrl.toString() + QLatin1Char('/') + fileName);
- if (isLocalScheme(url.scheme()) || url.isLocalFile()) {
- if (isLocalScheme(url.scheme())) {
- QString equivalentPath = QLatin1Char(':') + url.path();
- QString selectedPath = d->select(equivalentPath);
- url.setPath(selectedPath.remove(0, 1));
- } else {
- url = QUrl::fromLocalFile(d->select(url.toLocalFile()));
- }
+ if (isLocalScheme(url.scheme())) {
+ QString equivalentPath = QLatin1Char(':') + url.path();
+ QString selectedPath = d->select(equivalentPath);
+ url.setPath(selectedPath.remove(0, 1));
+ } else if (url.isLocalFile()) {
+ url = QUrl::fromLocalFile(d->select(url.toLocalFile()));
}
return url.toString();
}