From 711105058afe68407a0ed613335a83b6181112ed Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Wed, 31 Aug 2022 16:08:30 +0200 Subject: Apply Q_CONSTINIT where beneficial MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Applied Q_CONSTINIT to variables with static storage duration, but skipped the POD types with core constant initializers. Task-number: QTBUG-100486 Change-Id: Iaabf824e9cb0f29a405a149912200d4e4b3573c1 Reviewed-by: Thiago Macieira Reviewed-by: MÃ¥rten Nordheim --- src/gui/text/qfont.cpp | 2 +- src/gui/text/qtextlayout.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/gui/text') diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 316e92123e..1e26bb4f32 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -2828,7 +2828,7 @@ void QFontCache::cleanup() cache->setLocalData(nullptr); } -static QBasicAtomicInt font_cache_id = Q_BASIC_ATOMIC_INITIALIZER(0); +Q_CONSTINIT static QBasicAtomicInt font_cache_id = Q_BASIC_ATOMIC_INITIALIZER(0); QFontCache::QFontCache() : QObject(), total_cost(0), max_cost(min_cost), diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 365131f508..9cf5d8963b 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1712,7 +1712,7 @@ namespace { } }; -const QFixed LineBreakHelper::RightBearingNotCalculated = QFixed(1); +Q_CONSTINIT const QFixed LineBreakHelper::RightBearingNotCalculated = QFixed(1); inline bool LineBreakHelper::checkFullOtherwiseExtend(QScriptLine &line) { @@ -2507,7 +2507,7 @@ void QTextLine::draw_internal(QPainter *p, const QPointF &origPos, return; } - static QRectF maxFixedRect(-QFIXED_MAX / 2, -QFIXED_MAX / 2, QFIXED_MAX, QFIXED_MAX); + Q_CONSTINIT static QRectF maxFixedRect(-QFIXED_MAX / 2, -QFIXED_MAX / 2, QFIXED_MAX, QFIXED_MAX); const bool xlateToFixedRange = !maxFixedRect.contains(origPos); QPointF pos; if (Q_LIKELY(!xlateToFixedRange)) -- cgit v1.2.3