diff options
author | Volker Krause <volker.krause@kdab.com> | 2016-01-05 15:39:09 +0100 |
---|---|---|
committer | Volker Krause <volker.krause@kdab.com> | 2016-01-05 15:25:47 +0000 |
commit | d7bac6ddfad25c17315e572aa111459054f53c90 (patch) | |
tree | b043c6fe736c058b4398c16a8eced57f7a62184c /src | |
parent | 62df32a4a887bb13d80f51d7c575410ed4bf7d59 (diff) |
Avoid expensive QHash::keys() call in obj loader.
This hurts particularly bad here as the key type is too large for QList
to be efficient, causing 140k QList node allocations with my test model.
Change-Id: I46b8e347520a768d71ba6ed02d161c40e3af3c59
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/render/io/objloader.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/render/io/objloader.cpp b/src/render/io/objloader.cpp index a27ad7f21..8dd4150db 100644 --- a/src/render/io/objloader.cpp +++ b/src/render/io/objloader.cpp @@ -347,14 +347,12 @@ void ObjLoader::updateIndices(const QVector<QVector3D> &positions, if (hasNormals) m_normals.resize(vertexCount); - foreach (const FaceIndices &faceIndices, faceIndexMap.keys()) { - const int i = faceIndexMap.value(faceIndices); - - m_points[i] = positions[faceIndices.positionIndex]; + for (QHash<FaceIndices, unsigned int>::const_iterator it = faceIndexMap.begin(), endIt = faceIndexMap.end(); it != endIt; ++it) { + m_points[it.value()] = positions[it.key().positionIndex]; if (hasTexCoords) - m_texCoords[i] = std::numeric_limits<unsigned int>::max() != faceIndices.texCoordIndex ? texCoords[faceIndices.texCoordIndex] : QVector2D(); + m_texCoords[it.value()] = std::numeric_limits<unsigned int>::max() != it.key().texCoordIndex ? texCoords[it.key().texCoordIndex] : QVector2D(); if (hasNormals) - m_normals[i] = normals[faceIndices.normalIndex]; + m_normals[it.value()] = normals[it.key().normalIndex]; } // Now iterate over the face indices and lookup the unique vertex index |