summaryrefslogtreecommitdiff
path: root/src/libs/qmljs/qmljsdocument.cpp
diff options
context:
space:
mode:
authorChristian Kamm <christian.d.kamm@nokia.com>2010-08-31 10:23:48 +0200
committerChristian Kamm <christian.d.kamm@nokia.com>2010-08-31 10:25:02 +0200
commit2e8ec2f9e61a855cec878a00ca0156d1ec49c484 (patch)
tree3daa31dc2ff50d20f834744e5ad02d9cb91bad7b /src/libs/qmljs/qmljsdocument.cpp
parent3499fcb18e051ea506613bca9296e927a5d29f1c (diff)
downloadqt-creator-2e8ec2f9e61a855cec878a00ca0156d1ec49c484.tar.gz
QmlJS: Fix performance problem in Snapshot.
Don't use QMultiHash::values(key), it rebuilds the values list from scratch for each lookup. Reviewed-by: Roberto Raggi
Diffstat (limited to 'src/libs/qmljs/qmljsdocument.cpp')
-rw-r--r--src/libs/qmljs/qmljsdocument.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/libs/qmljs/qmljsdocument.cpp b/src/libs/qmljs/qmljsdocument.cpp
index cbd61313a9..8cad21c1d4 100644
--- a/src/libs/qmljs/qmljsdocument.cpp
+++ b/src/libs/qmljs/qmljsdocument.cpp
@@ -339,7 +339,7 @@ void Snapshot::insert(const Document::Ptr &document)
const QString path = document->path();
remove(fileName);
- _documentsByPath.insert(path, document);
+ _documentsByPath[path].append(document);
_documents.insert(fileName, document);
}
}
@@ -353,7 +353,12 @@ void Snapshot::remove(const QString &fileName)
{
Document::Ptr doc = _documents.value(fileName);
if (!doc.isNull()) {
- _documentsByPath.remove(doc->path(), doc);
+ const QString &path = doc->path();
+
+ QList<Document::Ptr> docs = _documentsByPath.value(path);
+ docs.removeAll(doc);
+ _documentsByPath[path] = docs;
+
_documents.remove(fileName);
}
}
@@ -378,7 +383,7 @@ Document::Ptr Snapshot::document(const QString &fileName) const
QList<Document::Ptr> Snapshot::documentsInDirectory(const QString &path) const
{
- return _documentsByPath.values(QDir::cleanPath(path));
+ return _documentsByPath.value(QDir::cleanPath(path));
}
LibraryInfo Snapshot::libraryInfo(const QString &path) const