diff options
author | Anton Kudryavtsev <a.kudryavtsev@netris.ru> | 2016-02-15 11:16:39 +0300 |
---|---|---|
committer | Anton Kudryavtsev <a.kudryavtsev@netris.ru> | 2016-04-08 19:35:26 +0000 |
commit | 89034600939bbfe241ba3d6136abf7bb6961db52 (patch) | |
tree | 569ed773351a496ddac552fff66859967695351f /src/gui/opengl/qopenglengineshadermanager.cpp | |
parent | f931e5e72d4617023bbea46cba2c0d61bb1efa4f (diff) |
QtBase: use erase and std::remove_if with QList and QVector
... instead of using removeAt in a loop, with quadratic complexity.
Change-Id: I38b49e56b12c396db9fc0f1b75d8fb43c503a7f6
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/gui/opengl/qopenglengineshadermanager.cpp')
-rw-r--r-- | src/gui/opengl/qopenglengineshadermanager.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/gui/opengl/qopenglengineshadermanager.cpp b/src/gui/opengl/qopenglengineshadermanager.cpp index 1bcb1c6760..4e3d14ba37 100644 --- a/src/gui/opengl/qopenglengineshadermanager.cpp +++ b/src/gui/opengl/qopenglengineshadermanager.cpp @@ -45,6 +45,8 @@ #include <QtGui/private/qopenglcontext_p.h> #include <QtCore/qthreadstorage.h> +#include <algorithm> + #if defined(QT_DEBUG) #include <QMetaEnum> #endif @@ -475,15 +477,16 @@ QOpenGLEngineShaderProg *QOpenGLEngineSharedShaders::findProgramInCache(const QO void QOpenGLEngineSharedShaders::cleanupCustomStage(QOpenGLCustomShaderStage* stage) { - // Remove any shader programs which has this as the custom shader src: - for (int i = 0; i < cachedPrograms.size(); ++i) { - QOpenGLEngineShaderProg *cachedProg = cachedPrograms[i]; + auto hasStageAsCustomShaderSouce = [stage](QOpenGLEngineShaderProg *cachedProg) -> bool { if (cachedProg->customStageSource == stage->source()) { delete cachedProg; - cachedPrograms.removeAt(i); - i--; + return true; } - } + return false; + }; + cachedPrograms.erase(std::remove_if(cachedPrograms.begin(), cachedPrograms.end(), + hasStageAsCustomShaderSouce), + cachedPrograms.end()); } |