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>
bb10
Marc Mutz 2015-12-22 20:58:15 +01:00
parent 3118f0b6b0
commit 6c28efb58b
1 changed files with 6 additions and 5 deletions

View File

@ -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) {