From 80fd691340e0e7c43a6216dc37a01e3a6509606e Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 25 Apr 2016 11:26:15 +0200 Subject: QXcbIntegration: simplify a switch ... by aggregating similar blocks under multiple case labels, and caching functions's return values. Even saves a few bytes in text size on optimized GCC 6.0 Linux AMD64 builds. Change-Id: I5784567a09732b4e55b64163b69e7a946f0783ae Reviewed-by: Lars Knoll --- src/plugins/platforms/xcb/qxcbintegration.cpp | 30 +++++++++++++++++---------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'src/plugins/platforms/xcb') diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index b5e03e68fe..703167c0cd 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -250,17 +250,25 @@ QPlatformOffscreenSurface *QXcbIntegration::createPlatformOffscreenSurface(QOffs bool QXcbIntegration::hasCapability(QPlatformIntegration::Capability cap) const { switch (cap) { - case ThreadedPixmaps: return true; - case OpenGL: return m_connections.first()->glIntegration(); - case ThreadedOpenGL: return m_connections.at(0)->threadedEventHandling() - && m_connections.at(0)->glIntegration() - && m_connections.at(0)->glIntegration()->supportsThreadedOpenGL(); - case WindowMasks: return true; - case MultipleWindows: return true; - case ForeignWindows: return true; - case SyncState: return true; - case RasterGLSurface: return true; - case SwitchableWidgetComposition: return true; + case OpenGL: + case ThreadedOpenGL: + { + const auto *connection = qAsConst(m_connections).first(); + if (const auto *integration = connection->glIntegration()) + return cap != ThreadedOpenGL + || (connection->threadedEventHandling() && integration->supportsThreadedOpenGL()); + return false; + } + + case ThreadedPixmaps: + case WindowMasks: + case MultipleWindows: + case ForeignWindows: + case SyncState: + case RasterGLSurface: + case SwitchableWidgetComposition: + return true; + default: return QPlatformIntegration::hasCapability(cap); } } -- cgit v1.2.3