summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Krause <volker.krause@kdab.com>2016-01-06 15:43:19 +0100
committerVolker Krause <volker.krause@kdab.com>2016-01-07 17:39:43 +0000
commit0b2dd1c329203448158469f8a39075f2a2f83242 (patch)
treed2be0f2872b583f77c7f12c953cc8261d7227234
parent9a23776ed1cb077bf839c6aad4ff901ea4fcc8c2 (diff)
downloadqt3d-0b2dd1c329203448158469f8a39075f2a2f83242.tar.gz
Add a few more QVector::reserve calls.
Found by heaptrack, all relevant for per-frame allocations. Change-Id: I12ef71f6bd1bca2ca78f4bfbd295265d840b4232 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
-rw-r--r--src/core/jobs/qaspectjobmanager.cpp1
-rw-r--r--src/render/backend/renderer.cpp1
-rw-r--r--src/render/backend/renderview.cpp2
3 files changed, 4 insertions, 0 deletions
diff --git a/src/core/jobs/qaspectjobmanager.cpp b/src/core/jobs/qaspectjobmanager.cpp
index b527e15e8..41e4b48eb 100644
--- a/src/core/jobs/qaspectjobmanager.cpp
+++ b/src/core/jobs/qaspectjobmanager.cpp
@@ -75,6 +75,7 @@ void QAspectJobManager::enqueueJobs(const QVector<QAspectJobPtr> &jobQueue)
// Convert QJobs to Tasks
QHash<QAspectJob *, AspectTaskRunnable *> tasksMap;
QVector<RunnableInterface *> taskList;
+ taskList.reserve(jobQueue.size());
Q_FOREACH (const QAspectJobPtr &job, jobQueue) {
AspectTaskRunnable *task = new AspectTaskRunnable();
task->m_job = job;
diff --git a/src/render/backend/renderer.cpp b/src/render/backend/renderer.cpp
index dbb91359c..3a1a8b1ca 100644
--- a/src/render/backend/renderer.cpp
+++ b/src/render/backend/renderer.cpp
@@ -958,6 +958,7 @@ Attribute *Renderer::updateBuffersAndAttributes(Geometry *geometry, RenderComman
Attribute *indexAttribute = Q_NULLPTR;
uint estimatedCount = 0;
+ m_dirtyAttributes.reserve(m_dirtyAttributes.size() + geometry->attributes().size());
Q_FOREACH (const QNodeId &attributeId, geometry->attributes()) {
// TO DO: Improvement we could store handles and use the non locking policy on the attributeManager
Attribute *attribute = m_nodesManager->attributeManager()->lookupResource(attributeId);
diff --git a/src/render/backend/renderview.cpp b/src/render/backend/renderview.cpp
index 36ad2a33c..905eaa281 100644
--- a/src/render/backend/renderview.cpp
+++ b/src/render/backend/renderview.cpp
@@ -475,6 +475,7 @@ void RenderView::buildRenderCommands(Entity *node, const Plane *planes)
parametersFromMaterialEffectTechnique(&parameters, m_manager->parameterManager(), material, effect, technique);
// 1 RenderCommand per RenderPass pass on an Entity with a Mesh
+ m_commands.reserve(m_commands.size() + passes.size());
Q_FOREACH (RenderPass *pass, passes) {
// Add the RenderPass Parameters
@@ -508,6 +509,7 @@ void RenderView::buildRenderCommands(Entity *node, const Plane *planes)
// Replace with more sophisticated mechanisms later.
std::sort(m_lightSources.begin(), m_lightSources.end(), LightSourceCompare(node));
QVector<LightSource> activeLightSources; // NB! the total number of lights here may still exceed MAX_LIGHTS
+ activeLightSources.reserve(m_lightSources.count());
int lightCount = 0;
for (int i = 0; i < m_lightSources.count() && lightCount < MAX_LIGHTS; ++i) {
activeLightSources.append(m_lightSources[i]);