From 8da3eea4fb702c2dc369c1628e91a034569aa9f0 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 25 Jun 2019 22:21:44 +0200 Subject: Optimize some atomic counters Define the static QAtomic at file scope to avoid GCC's pessimisation with function-static QAtomic (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79561), and make sure the initial value is 0, so it ends up in BSS, not TEXT. In QRhi..., don't create a static instance of the wrapper class, use a file- static atomic, too. This turns the class into a glorified namespace. Change-Id: I707f628e2b434330028077223071716d5704ba32 Reviewed-by: Thiago Macieira --- src/platformsupport/fbconvenience/qfbwindow.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/platformsupport') diff --git a/src/platformsupport/fbconvenience/qfbwindow.cpp b/src/platformsupport/fbconvenience/qfbwindow.cpp index 36f92b8cea..9f5f87d9d6 100644 --- a/src/platformsupport/fbconvenience/qfbwindow.cpp +++ b/src/platformsupport/fbconvenience/qfbwindow.cpp @@ -45,11 +45,12 @@ QT_BEGIN_NAMESPACE +static QBasicAtomicInt winIdGenerator = Q_BASIC_ATOMIC_INITIALIZER(0); + QFbWindow::QFbWindow(QWindow *window) : QPlatformWindow(window), mBackingStore(0), mWindowState(Qt::WindowNoState) { - static QAtomicInt winIdGenerator(1); - mWindowId = winIdGenerator.fetchAndAddRelaxed(1); + mWindowId = winIdGenerator.fetchAndAddRelaxed(1) + 1; } QFbWindow::~QFbWindow() -- cgit v1.2.3