From 93e2ce4bfd099279d87cf7cfffca864a06099409 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 19 Jul 2013 11:46:42 +0200 Subject: [PATCH] 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 --- effects.cpp | 2 ++ effects.h | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/effects.cpp b/effects.cpp index 3577535bd1..a4ad2010b5 100644 --- a/effects.cpp +++ b/effects.cpp @@ -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 diff --git a/effects.h b/effects.h index 1850089499..43f2c14642 100644 --- a/effects.h +++ b/effects.h @@ -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;