From 21e0cb7a42bd4f5f7173a93971217271245efde6 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 16 May 2022 17:43:54 +0200 Subject: 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 Reviewed-by: Volker Hilsheimer Reviewed-by: Qt CI Bot Reviewed-by: Giuseppe D'Angelo --- src/gui/kernel/qkeysequence.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index 5e5b5d4eee..6f0479b0d3 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -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) -- cgit v1.2.3