QKeySequence: constinit ALL the things

C++20 constinit acts as a static_assertion that the initialiation of
the object doesn't incur runtime initialization overhead.

Task-number: QTBUG-100486
Change-Id: I818f5ca9703273cd41e44e5ce7085cb5c643ca8e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Laszlo Papp <lpapp@kde.org>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Marc Mutz 2022-05-19 10:41:02 +02:00
parent dface58142
commit bc922223cf

View File

@ -25,7 +25,7 @@ QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
#if defined(Q_OS_MACOS) || defined(Q_CLANG_QDOC)
static bool qt_sequence_no_mnemonics = true;
Q_CONSTINIT static bool qt_sequence_no_mnemonics = true;
struct MacSpecialKey {
int key;
ushort macSymbol;
@ -117,7 +117,7 @@ static int qtkeyForMacSymbol(const QChar ch)
}
#else
static bool qt_sequence_no_mnemonics = false;
Q_CONSTINIT static bool qt_sequence_no_mnemonics = false;
#endif
/*!
@ -797,7 +797,7 @@ QKeySequence::QKeySequence(StandardKey key)
*/
QKeySequence::QKeySequence()
{
static QKeySequencePrivate shared_empty;
Q_CONSTINIT static QKeySequencePrivate shared_empty;
d = &shared_empty;
d->ref.ref();
}