aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/folderlistmodel
diff options
context:
space:
mode:
authorAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-05-05 14:38:16 +0300
committerAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-05-27 10:20:45 +0000
commit8b99e2019a860d31e49e0fbe9bcfd9981dc2b768 (patch)
tree5676e47db0f57eef4da6a42e58d40e3203c1e283 /src/imports/folderlistmodel
parent818abf6a8cc9c862c10e14700f41b63006e9ecca (diff)
Imports: de-duplicate some expensive calls
QMetaMethod::parameterNames() contains internal loop, and we had quadratic behavior. Since operator[] was used with temp object, also we had detach()ing. QUrl::path() contains memory allocation. To avoid these issues cache results of functions. Change-Id: Ie4c3f0573a000342aff44de0dd4f744a146bb935 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/imports/folderlistmodel')
-rw-r--r--src/imports/folderlistmodel/qquickfolderlistmodel.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp
index 66af37c40c..1c94fddecf 100644
--- a/src/imports/folderlistmodel/qquickfolderlistmodel.cpp
+++ b/src/imports/folderlistmodel/qquickfolderlistmodel.cpp
@@ -491,10 +491,11 @@ QUrl QQuickFolderListModel::parentFolder() const
return QUrl();
localFile = dir.path();
} else {
- const int pos = d->currentDir.path().lastIndexOf(QLatin1Char('/'));
+ const QString path = d->currentDir.path();
+ const int pos = path.lastIndexOf(QLatin1Char('/'));
if (pos <= 0)
return QUrl();
- localFile = d->currentDir.path().left(pos);
+ localFile = path.left(pos);
}
return QUrl::fromLocalFile(localFile);
}