summaryrefslogtreecommitdiffstats
path: root/src/corelib/animation
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-08-17 10:17:27 +0200
committerOlivier Goffart <ogoffart@trolltech.com>2009-08-19 17:50:56 +0200
commit919b723088b8617b202b92d80b8d0983e4fd9500 (patch)
tree022472bc157e4f4e888929fe29f5b11ee8fef371 /src/corelib/animation
parent555fafe46e26b352e9d8ab5586910591761ab5ad (diff)
Improve memory usage of the connectionlists inside QObject
... by not allocating space for slots in the vector. Before, the vector uses the signal index as index. The problem is that the slots and signal are mixed in the same index space. We solve the problem by having a different index space for the signal in the connectionlists vector. All we need to do is to add the information about the number of signals in the moc. Also, we are not connecting to cloned signal but only to the orginial ones. For example, destroyed(QObject * = 0) would generate two signal, we now only connect to the first one. This also improve a little bit the performence while activating signals since it removed one call to indexOfMethod. Reviewed-by: Brad
Diffstat (limited to 'src/corelib/animation')
-rw-r--r--src/corelib/animation/qvariantanimation.cpp15
-rw-r--r--src/corelib/animation/qvariantanimation_p.h2
2 files changed, 8 insertions, 9 deletions
diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp
index fc11815a6c..696a95a9fb 100644
--- a/src/corelib/animation/qvariantanimation.cpp
+++ b/src/corelib/animation/qvariantanimation.cpp
@@ -137,7 +137,6 @@ QT_BEGIN_NAMESPACE
\sa currentValue
*/
-
static bool animationValueLessThan(const QVariantAnimation::KeyValue &p1, const QVariantAnimation::KeyValue &p2)
{
return p1.first < p2.first;
@@ -178,11 +177,8 @@ template<> Q_INLINE_TEMPLATE QLineF _q_interpolate(const QLineF &f, const QLineF
return QLineF( _q_interpolate(f.p1(), t.p1(), progress), _q_interpolate(f.p2(), t.p2(), progress));
}
-QVariantAnimationPrivate::QVariantAnimationPrivate() : duration(250), interpolator(&defaultInterpolator),
- changedSignalMask(1 << QVariantAnimation::staticMetaObject.indexOfSignal("valueChanged(QVariant)"))
-{
- //we keep the mask so that we emit valueChanged only when needed (for performance reasons)
-}
+QVariantAnimationPrivate::QVariantAnimationPrivate() : duration(250), interpolator(&defaultInterpolator)
+{ }
void QVariantAnimationPrivate::convertValues(int t)
{
@@ -278,7 +274,12 @@ void QVariantAnimationPrivate::setCurrentValueForProgress(const qreal progress)
localProgress);
qSwap(currentValue, ret);
q->updateCurrentValue(currentValue);
- if ((connectedSignals[0] & changedSignalMask) && currentValue != ret) {
+ static QBasicAtomicInt changedSignalIndex = Q_BASIC_ATOMIC_INITIALIZER(0);
+ if (!changedSignalIndex) {
+ //we keep the mask so that we emit valueChanged only when needed (for performance reasons)
+ changedSignalIndex.testAndSetRelaxed(0, signalIndex("valueChanged(QVariant)"));
+ }
+ if (isSignalConnected(changedSignalIndex) && currentValue != ret) {
//the value has changed
emit q->valueChanged(currentValue);
}
diff --git a/src/corelib/animation/qvariantanimation_p.h b/src/corelib/animation/qvariantanimation_p.h
index ef57a4cabf..ce625f1c17 100644
--- a/src/corelib/animation/qvariantanimation_p.h
+++ b/src/corelib/animation/qvariantanimation_p.h
@@ -93,8 +93,6 @@ public:
QVariantAnimation::Interpolator interpolator;
- const quint32 changedSignalMask;
-
void setCurrentValueForProgress(const qreal progress);
void recalculateCurrentInterval(bool force=false);
void setValueAt(qreal, const QVariant &);