summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-12-22 20:58:15 +0100
committerMarc Mutz <marc.mutz@kdab.com>2015-12-26 07:46:09 +0000
commit6c28efb58b5b9a80e445258102e4c1641d65b618 (patch)
tree3cbdf013b1d286444e13b99e629d0663f1504da6 /src/opengl
parent3118f0b6b0d16fdb5a34a210aff47b916068fa2e (diff)
QGLShaderProgram: hoist some constant expressions out of a loop
d->programGuard and its ID don't change when calling a GL function, so check them only once, before entering the loop, instead of once per iteration. Cache d->programGuard->id(). Change-Id: I398da7a76823b2eb854b7b9d5af512adf9969fc9 Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/qglshaderprogram.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp
index 0617c36236..790007144c 100644
--- a/src/opengl/qglshaderprogram.cpp
+++ b/src/opengl/qglshaderprogram.cpp
@@ -874,11 +874,12 @@ void QGLShaderProgram::removeAllShaders()
{
Q_D(QGLShaderProgram);
d->removingShaders = true;
- foreach (QGLShader *shader, d->shaders) {
- if (d->programGuard && d->programGuard->id()
- && shader && shader->d_func()->shaderGuard)
- {
- d->glfuncs->glDetachShader(d->programGuard->id(), shader->d_func()->shaderGuard->id());
+ if (d->programGuard) {
+ if (const auto programGuardId = d->programGuard->id()) {
+ foreach (QGLShader *shader, d->shaders) {
+ if (shader && shader->d_func()->shaderGuard)
+ d->glfuncs->glDetachShader(programGuardId, shader->d_func()->shaderGuard->id());
+ }
}
}
foreach (QGLShader *shader, d->anonShaders) {