diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2015-11-12 10:16:22 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2015-11-29 22:59:17 +0000 |
commit | 51089a5742a79467221b5781cb35a8cea023febf (patch) | |
tree | 95f765fa452cdfaa12f986e4d228d9a958c95100 /src/opengl/gl2paintengineex | |
parent | 14d189f7875b7def6f9745bfd20527a0fce19a44 (diff) |
Use Q_UNLIKELY for every qFatal()/qCritical()
If, after checking a condition, we issue a qFatal()
or a qCritical(), by definition that check is
unlikely to be true.
Tell the compiler so it can move the error handling
code out of the normal code path to increase the
effective icache size.
Moved conditional code around where possible so that
we could always use Q_UNLIKELY, instead of having to
revert to Q_LIKELY here and there.
In some cases, simplified the expressions newly wrapped
in Q_UNLIKELY as a drive-by.
Change-Id: I67537d62b04bc6977d69254690c5ebbdf98bfd6d
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/opengl/gl2paintengineex')
-rw-r--r-- | src/opengl/gl2paintengineex/qglengineshadermanager.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp index 903f34f939..984590435d 100644 --- a/src/opengl/gl2paintengineex/qglengineshadermanager.cpp +++ b/src/opengl/gl2paintengineex/qglengineshadermanager.cpp @@ -188,7 +188,7 @@ QGLEngineSharedShaders::QGLEngineSharedShaders(const QGLContext* context) #if defined(QT_DEBUG) // Check that all the elements have been filled: for (int i = 0; i < TotalSnippetCount; ++i) { - if (qShaderSnippets[i] == 0) { + if (Q_UNLIKELY(!qShaderSnippets[i])) { qFatal("Shader snippet for %s (#%d) is missing!", snippetNameStr(SnippetName(i)).constData(), i); } @@ -237,11 +237,11 @@ QGLEngineSharedShaders::QGLEngineSharedShaders(const QGLContext* context) simpleShaderProg->link(); - if (simpleShaderProg->isLinked()) { + if (Q_UNLIKELY(!simpleShaderProg->isLinked())) { + qCritical("Errors linking simple shader: %s", qPrintable(simpleShaderProg->log())); + } else { if (!inCache) simpleShaderCache.store(simpleShaderProg, context); - } else { - qCritical("Errors linking simple shader: %s", qPrintable(simpleShaderProg->log())); } // Compile the blit shader: @@ -278,11 +278,11 @@ QGLEngineSharedShaders::QGLEngineSharedShaders(const QGLContext* context) } blitShaderProg->link(); - if (blitShaderProg->isLinked()) { + if (Q_UNLIKELY(!blitShaderProg->isLinked())) { + qCritical("Errors linking blit shader: %s", qPrintable(blitShaderProg->log())); + } else { if (!inCache) blitShaderCache.store(blitShaderProg, context); - } else { - qCritical("Errors linking blit shader: %s", qPrintable(blitShaderProg->log())); } #ifdef QT_GL_SHARED_SHADER_DEBUG |