summaryrefslogtreecommitdiffstats
path: root/src/widgets/graphicsview/qgraphicsitemanimation.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-06-27 16:40:45 +0200
committerMarc Mutz <marc.mutz@kdab.com>2015-06-28 21:11:00 +0000
commit99d9a683b12dbff594e24849e981df78619e0ff1 (patch)
tree63dbbe61cf2ca9a5373816073ed4a3a47418b9d3 /src/widgets/graphicsview/qgraphicsitemanimation.cpp
parent1a1ca59e2db9bd0e888bbae7806993fe03ee0153 (diff)
QGraphicsItemAnimationPrivate: replace a sort with a rotate
There's really no need to sort the whole collection if you a) know it's already sorted and b) already know its final position, because you looked it up using lower_bound a line up. Instead of appending and sorting the whole thing, simply append and rotate into place, conveniently packaged as positional insert. Also reverse the check for presence: less negations: more readable. Change-Id: Id23f108b64976061f666f517fbc436d3c72dd25b Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/widgets/graphicsview/qgraphicsitemanimation.cpp')
-rw-r--r--src/widgets/graphicsview/qgraphicsitemanimation.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/widgets/graphicsview/qgraphicsitemanimation.cpp b/src/widgets/graphicsview/qgraphicsitemanimation.cpp
index f983da015c..585539de94 100644
--- a/src/widgets/graphicsview/qgraphicsitemanimation.cpp
+++ b/src/widgets/graphicsview/qgraphicsitemanimation.cpp
@@ -176,12 +176,10 @@ void QGraphicsItemAnimationPrivate::insertUniquePair(qreal step, qreal value, QV
const Pair pair = { step, value };
const QVector<Pair>::iterator result = std::lower_bound(binList->begin(), binList->end(), pair);
- if ((result != binList->end()) && !(pair < *result))
+ if (result == binList->end() || pair < *result)
+ binList->insert(result, pair);
+ else
result->value = value;
- else {
- *binList << pair;
- std::sort(binList->begin(), binList->end());
- }
}
/*!