From 51089a5742a79467221b5781cb35a8cea023febf Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 12 Nov 2015 10:16:22 +0100 Subject: 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 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/plugins/platforms/minimalegl/qminimaleglscreen.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/plugins/platforms/minimalegl') diff --git a/src/plugins/platforms/minimalegl/qminimaleglscreen.cpp b/src/plugins/platforms/minimalegl/qminimaleglscreen.cpp index 59062338cb..093a1c689c 100644 --- a/src/plugins/platforms/minimalegl/qminimaleglscreen.cpp +++ b/src/plugins/platforms/minimalegl/qminimaleglscreen.cpp @@ -74,19 +74,19 @@ QMinimalEglScreen::QMinimalEglScreen(EGLNativeDisplayType display) EGLint major, minor; - if (!eglBindAPI(EGL_OPENGL_ES_API)) { + if (Q_UNLIKELY(!eglBindAPI(EGL_OPENGL_ES_API))) { qWarning("Could not bind GL_ES API\n"); qFatal("EGL error"); } m_dpy = eglGetDisplay(display); - if (m_dpy == EGL_NO_DISPLAY) { + if (Q_UNLIKELY(m_dpy == EGL_NO_DISPLAY)) { qWarning("Could not open egl display\n"); qFatal("EGL error"); } qWarning("Opened display %p\n", m_dpy); - if (!eglInitialize(m_dpy, &major, &minor)) { + if (Q_UNLIKELY(!eglInitialize(m_dpy, &major, &minor))) { qWarning("Could not initialize egl display\n"); qFatal("EGL error"); } @@ -135,9 +135,9 @@ void QMinimalEglScreen::createAndSetPlatformContext() EGLNativeWindowType eglWindow = 0; #ifdef Q_OPENKODE - if (kdInitializeNV() == KD_ENOTINITIALIZED) { + if (Q_UNLIKELY(kdInitializeNV() == KD_ENOTINITIALIZED)) qFatal("Did not manage to initialize openkode"); - } + KDWindow *window = kdCreateWindow(m_dpy,config,0); kdRealizeWindow(window,&eglWindow); @@ -148,7 +148,7 @@ void QMinimalEglScreen::createAndSetPlatformContext() #endif m_surface = eglCreateWindowSurface(m_dpy, config, eglWindow, NULL); - if (m_surface == EGL_NO_SURFACE) { + if (Q_UNLIKELY(m_surface == EGL_NO_SURFACE)) { qWarning("Could not create the egl surface: error = 0x%x\n", eglGetError()); eglTerminate(m_dpy); qFatal("EGL error"); -- cgit v1.2.3