From 04d6495bf773a6bb0d4fa6980df22d3b81a605b0 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 14 Feb 2017 01:26:25 +0100 Subject: Make some atomic counters zero-based A variable of static storage duration that is not zero-initialized takes up space in the DATA segment of the executable. By making the counters start at zero and adding the initial value afterwards, we move them over to the BSS segment, which does not take up space in the executable. Wrap atomics used across function boundaries into small functions, to avoid code duplication and to increase readability. Change-Id: Ida6ed316ecb8fe20da62a9577161349e14de5aed Reviewed-by: Thiago Macieira --- src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/opengl') diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp index 047b681bcb..c1c5661da4 100644 --- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp +++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp @@ -45,7 +45,11 @@ QT_BEGIN_NAMESPACE -QBasicAtomicInt qgltextureglyphcache_serial_number = Q_BASIC_ATOMIC_INITIALIZER(1); +static int next_qgltextureglyphcache_serial_number() +{ + static QBasicAtomicInt serial; + return 1 + serial.fetchAndAddRelaxed(1); +} QGLTextureGlyphCache::QGLTextureGlyphCache(QFontEngine::GlyphFormat format, const QTransform &matrix) : QImageTextureGlyphCache(format, matrix) @@ -53,7 +57,7 @@ QGLTextureGlyphCache::QGLTextureGlyphCache(QFontEngine::GlyphFormat format, cons , pex(0) , m_blitProgram(0) , m_filterMode(Nearest) - , m_serialNumber(qgltextureglyphcache_serial_number.fetchAndAddRelaxed(1)) + , m_serialNumber(next_qgltextureglyphcache_serial_number()) { #ifdef QT_GL_TEXTURE_GLYPH_CACHE_DEBUG qDebug(" -> QGLTextureGlyphCache() %p for context %p.", this, QOpenGLContext::currentContext()); -- cgit v1.2.3