QQuickParticleSystem: Micro-optimize m_emitters' handling of null pointers.
authorRobin Burchell <robin.burchell@viroteck.net>
Fri, 17 Oct 2014 23:32:05 +0000 (01:32 +0200)
committerRobin Burchell <robin.burchell@viroteck.net>
Mon, 20 Oct 2014 11:14:02 +0000 (13:14 +0200)
This shaves off around 35ms from samegame setup of a large game.

Change-Id: I91cb7e8d8db5da672e0dcf30a3c0bb0fa855c93f
Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
src/particles/qquickparticlesystem.cpp

index 86445ef..a1367cf 100644 (file)
@@ -911,9 +911,6 @@ void QQuickParticleSystem::emittersChanged()
     if (!m_componentComplete)
         return;
 
-    m_emitters.removeAll(0);
-
-
     QList<int> previousSizes;
     QList<int> newSizes;
     for (int i=0; i<m_nextGroupId; i++) {
@@ -921,7 +918,15 @@ void QQuickParticleSystem::emittersChanged()
         newSizes << 0;
     }
 
-    foreach (QQuickParticleEmitter* e, m_emitters) {//Populate groups and set sizes.
+    // Populate groups and set sizes.
+    for (int i = 0; i < m_emitters.count(); ++i) {
+        QQuickParticleEmitter *e = m_emitters.at(i);
+        if (!e) {
+            m_emitters.removeAt(i);
+            i--;
+            continue;
+        }
+
         if (!e->group().isEmpty() &&
             !groupIds.contains(e->group())) {
             int id = m_nextGroupId++;