aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmlprofiler
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@digia.com>2014-03-26 16:23:52 +0100
committerUlf Hermann <ulf.hermann@digia.com>2014-03-31 10:55:06 +0200
commit20e2d1eb7d21ea36a654090544ac592854bd9f7e (patch)
tree0a51628dedd19ca2c65233336c715197552bb7e1 /src/plugins/qmlprofiler
parentcdec724ea599dd445452778dff79224637cc8321 (diff)
QmlProfiler: Avoid indexOf and contains on list of strings
The iteration and comparison done by that takes significant time for large traces. Task-number: QTCREATORBUG-11823 Change-Id: I706b42f64ef0fd8b89229f51e52f0faaaf61d87a Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Diffstat (limited to 'src/plugins/qmlprofiler')
-rw-r--r--src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.cpp b/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.cpp
index 1488c5e47aa..cfcea9838e0 100644
--- a/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.cpp
+++ b/src/plugins/qmlprofiler/qmlprofilertimelinemodelproxy.cpp
@@ -119,6 +119,8 @@ void BasicTimelineModel::loadData()
d->prepare();
+ QMap<QString, int> eventIdsByHash;
+
// collect events
const QVector<QmlProfilerDataModel::QmlEventData> eventList = simpleModel->getEvents();
foreach (const QmlProfilerDataModel::QmlEventData &event, eventList) {
@@ -130,7 +132,9 @@ void BasicTimelineModel::loadData()
QString eventHash = QmlProfilerDataModel::getHashString(event);
// store in dictionary
- if (!d->eventHashes.contains(eventHash)) {
+ int eventId;
+ QMap<QString, int>::const_iterator i = eventIdsByHash.constFind(eventHash);
+ if (i == eventIdsByHash.cend()) {
QmlRangeEventData rangeEventData = {
event.displayName,
event.data.join(QLatin1String(" ")),
@@ -139,11 +143,15 @@ void BasicTimelineModel::loadData()
lastEventId++ // event id
};
d->eventDict << rangeEventData;
+ eventId = d->eventHashes.size();
+ eventIdsByHash.insert(eventHash, eventId);
d->eventHashes << eventHash;
+ } else {
+ eventId = i.value();
}
// store starttime-based instance
- d->insert(event.startTime, event.duration, QmlRangeEventStartInstance(d->eventHashes.indexOf(eventHash)));
+ d->insert(event.startTime, event.duration, QmlRangeEventStartInstance(eventId));
d->modelManager->modelProxyCountUpdated(d->modelId, d->count(), eventList.count() * 6);
}