aboutsummaryrefslogtreecommitdiffstats
path: root/src/particles/qquickcustomparticle.cpp
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@digia.com>2016-03-03 14:54:31 +0100
committerErik Verbruggen <erik.verbruggen@theqtcompany.com>2016-03-04 13:54:50 +0000
commit5a9734c0d071b7490b3ef7edf5f080786dc89f79 (patch)
treeef8d18707d2f65df718ea785745d079ff3558fb8 /src/particles/qquickcustomparticle.cpp
parent554566788f585caaef14d929cee6557ad929e06e (diff)
Particles: reduce excessive hash accesses to a more passable level.
By caching the group id in the particle emitter, and groups in the painter. Test case: samegame, 1 player, click 1 set of 3 stones, quit. QQuickParticleSystem::emittersChanged(), before patch: - 64M instr. inclusive - 145,880 calls to findNode (29M instr.) after: - 21M instr. inclusive - 0 calls to findNode - 25 calls to QQuickParticlePainter::recalculateGroupIds (9800 instr. inclusive). Change-Id: I4aba9d50100513c6b7cdd230e30b3aecaf84485a Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/particles/qquickcustomparticle.cpp')
-rw-r--r--src/particles/qquickcustomparticle.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/particles/qquickcustomparticle.cpp b/src/particles/qquickcustomparticle.cpp
index 97cfdc7bf9..32b2fd847e 100644
--- a/src/particles/qquickcustomparticle.cpp
+++ b/src/particles/qquickcustomparticle.cpp
@@ -324,19 +324,18 @@ QQuickShaderEffectNode* QQuickCustomParticle::buildCustomNodes()
return 0;
}
- if (m_groups.isEmpty())
+ if (groups().isEmpty())
return 0;
QQuickShaderEffectNode *rootNode = 0;
QQuickShaderEffectMaterial *material = new QQuickShaderEffectMaterial;
m_dirtyProgram = true;
- foreach (const QString &str, m_groups){
- int gIdx = m_system->groupIds[str];
- int count = m_system->groupData[gIdx]->size();
+ for (auto groupId : groupIds()) {
+ int count = m_system->groupData[groupId]->size();
QQuickShaderEffectNode* node = new QQuickShaderEffectNode();
- m_nodes.insert(gIdx, node);
+ m_nodes.insert(groupId, node);
node->setMaterial(material);
@@ -349,7 +348,7 @@ QQuickShaderEffectNode* QQuickCustomParticle::buildCustomNodes()
node->setFlag(QSGNode::OwnsGeometry, true);
PlainVertex *vertices = (PlainVertex *) g->vertexData();
for (int p=0; p < count; ++p) {
- commit(gIdx, p);
+ commit(groupId, p);
vertices[0].tx = 0;
vertices[0].ty = 0;