aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/util/qquickspringanimation.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-02-23 13:45:44 +0100
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-02-26 15:13:40 +0000
commit3b5447661a2c9b4bbced202e116a7edeaaf9a065 (patch)
treeff7486e826942ac5339135913521bb28cf5ceb37 /src/quick/util/qquickspringanimation.cpp
parent5163c11952a39458dd6d7ba10391c2b39ccdf86a (diff)
QtQuick: Micro-optimize iterator loops.
Avoid repeated instantiation of end() in loops, use variable instead. Change-Id: I6ab1fe2b82406d5ee91710a0333587ffb82c04d4 Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
Diffstat (limited to 'src/quick/util/qquickspringanimation.cpp')
-rw-r--r--src/quick/util/qquickspringanimation.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/quick/util/qquickspringanimation.cpp b/src/quick/util/qquickspringanimation.cpp
index f2eee6a802..b68afbecdd 100644
--- a/src/quick/util/qquickspringanimation.cpp
+++ b/src/quick/util/qquickspringanimation.cpp
@@ -86,6 +86,7 @@ public:
bool haveModulus : 1;
bool skipUpdate : 1;
typedef QHash<QQmlProperty, QSpringAnimation*> ActiveAnimationHash;
+ typedef ActiveAnimationHash::Iterator ActiveAnimationHashIt;
void clearTemplate() { animationTemplate = 0; }
@@ -161,14 +162,12 @@ QSpringAnimation::~QSpringAnimation()
{
if (animationTemplate) {
if (target.object()) {
- QSpringAnimation::ActiveAnimationHash::iterator it =
- animationTemplate->activeAnimations.find(target);
+ ActiveAnimationHashIt it = animationTemplate->activeAnimations.find(target);
if (it != animationTemplate->activeAnimations.end() && it.value() == this)
animationTemplate->activeAnimations.erase(it);
} else {
//target is no longer valid, need to search linearly
- QSpringAnimation::ActiveAnimationHash::iterator it;
- for (it = animationTemplate->activeAnimations.begin(); it != animationTemplate->activeAnimations.end(); ++it) {
+ for (ActiveAnimationHashIt it = animationTemplate->activeAnimations.begin(); it != animationTemplate->activeAnimations.end(); ++it) {
if (it.value() == this) {
animationTemplate->activeAnimations.erase(it);
break;
@@ -329,8 +328,7 @@ void QQuickSpringAnimationPrivate::updateMode()
mode = QSpringAnimation::Spring;
else {
mode = QSpringAnimation::Velocity;
- QSpringAnimation::ActiveAnimationHash::iterator it;
- for (it = activeAnimations.begin(); it != activeAnimations.end(); ++it) {
+ for (QSpringAnimation::ActiveAnimationHashIt it = activeAnimations.begin(), end = activeAnimations.end(); it != end; ++it) {
QSpringAnimation *animation = *it;
animation->startTime = animation->lastTime;
qreal dist = qAbs(animation->currentValue - animation->to);
@@ -378,10 +376,8 @@ QQuickSpringAnimation::QQuickSpringAnimation(QObject *parent)
QQuickSpringAnimation::~QQuickSpringAnimation()
{
Q_D(QQuickSpringAnimation);
- QSpringAnimation::ActiveAnimationHash::iterator it;
- for (it = d->activeAnimations.begin(); it != d->activeAnimations.end(); ++it) {
+ for (QSpringAnimation::ActiveAnimationHashIt it = d->activeAnimations.begin(), end = d->activeAnimations.end(); it != end; ++it)
it.value()->clearTemplate();
- }
}
/*!