Use QVector instead of QList for the list of active effects

We only append to the list, so the advantage of insertion into QList
does not matter.

Thanks to Milian Wolff to point this out in his Akademy talk [1] and for
pointing me to Marc Mutz blog post [2] discussing this topic and
recommending the usage of QVector over QList.

[1] http://milianw.de/files/apps-on-speed-akademy2013/index.html
[2] http://marcmutz.wordpress.com/effective-qt/containers/

REVIEW: 111597
This commit is contained in:
Martin Gräßlin 2013-07-19 11:46:42 +02:00
parent 13ad458cca
commit 93e2ce4bfd
2 changed files with 4 additions and 2 deletions

View file

@ -488,6 +488,7 @@ bool EffectsHandlerImpl::decorationSupportsBlurBehind() const
void EffectsHandlerImpl::startPaint()
{
m_activeEffects.clear();
m_activeEffects.reserve(loaded_effects.count());
for(QVector< KWin::EffectPair >::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) {
if (it->second->isActive()) {
m_activeEffects << it->second;
@ -1552,6 +1553,7 @@ void EffectsHandlerImpl::effectsChanged()
// kDebug(1212) << effect.first;
loaded_effects.append(effect);
}
m_activeEffects.reserve(loaded_effects.count());
}
QStringList EffectsHandlerImpl::activeEffects() const

View file

@ -253,9 +253,9 @@ private Q_SLOTS:
void slotEffectsQueried();
private:
QList< Effect* > m_activeEffects;
typedef QList< Effect*> EffectsList;
typedef QVector< Effect*> EffectsList;
typedef EffectsList::const_iterator EffectsIterator;
EffectsList m_activeEffects;
EffectsIterator m_currentDrawWindowIterator;
EffectsIterator m_currentPaintWindowIterator;
EffectsIterator m_currentPaintEffectFrameIterator;