Tracing: Improve event adding performance by using at() instead of []

This speeds up adding events using Timeline::TimelineModel::insert()
by 20% in release mode and reduces it to a third in debug mode by
avoiding a check whether the container is detached.

Change-Id: I3c81120047c33b3ce20cfb4cd309cbe17694b141
Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
Tim Henning
2019-05-28 10:47:47 +02:00
committed by tim.henning
parent effbd54ae2
commit d25c7ea137

View File

@@ -90,7 +90,7 @@ public:
ranges.prepend(start);
return 0;
}
const Range &range = ranges[--i];
const Range &range = ranges.at(--i);
if (range.start < start.start || (range.start == start.start &&
range.duration >= start.duration)) {
ranges.insert(++i, start);
@@ -106,7 +106,7 @@ public:
endTimes.prepend(end);
return 0;
}
if (endTimes[--i].end <= end.end) {
if (endTimes.at(--i).end <= end.end) {
endTimes.insert(++i, end);
return i;
}