QKeySequence/Mac: remove NumEntries variable

Keep it DRY. Just let the compiler figure out the size.

Pick-to: 6.3 6.2
Change-Id: I2bf1c44d4e2060a9398700d16ab98d67c849814c
Reviewed-by: Laszlo Papp <lpapp@kde.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
bb10
Marc Mutz 2022-05-16 17:43:54 +02:00
parent 22ae4ba3b7
commit 21e0cb7a42
1 changed files with 3 additions and 6 deletions

View File

@ -59,7 +59,6 @@ static const MacSpecialKey entries[] = {
{ Qt::Key_Alt, kOptionUnicode },
{ Qt::Key_CapsLock, 0x21EA },
};
static const int NumEntries = std::size(entries);
static bool operator<(const MacSpecialKey &entry, int key)
{
@ -71,12 +70,11 @@ static bool operator<(int key, const MacSpecialKey &entry)
return key < entry.key;
}
static const MacSpecialKey * const MacSpecialKeyEntriesEnd = entries + NumEntries;
QChar qt_macSymbolForQtKey(int key)
{
const MacSpecialKey *i = std::lower_bound(entries, MacSpecialKeyEntriesEnd, key);
if ((i == MacSpecialKeyEntriesEnd) || (key < *i))
const auto i = std::lower_bound(std::begin(entries), std::end(entries), key);
if (i == std::end(entries) || key < *i)
return QChar();
ushort macSymbol = i->macSymbol;
if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)
@ -93,8 +91,7 @@ QChar qt_macSymbolForQtKey(int key)
static int qtkeyForMacSymbol(const QChar ch)
{
const ushort unicode = ch.unicode();
for (int i = 0; i < NumEntries; ++i) {
const MacSpecialKey &entry = entries[i];
for (const MacSpecialKey &entry : entries) {
if (entry.macSymbol == unicode) {
int key = entry.key;
if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)