From cbc9d8947842b97f28e3acb2d87d80b4861d00b9 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 5 Jun 2019 21:59:46 +0200 Subject: QInputDeviceManager: replace a QMap with a std::array MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QInputDeviceManager::DeviceType is a (non-flag) enum with all of five values. Using a self-rebalancing rb-tree to map these to an int is overkill. An array can do the job just as well and better, given the enum values are consecutive, and even if some don't make sense (like Unknown), the waste caused by unused array slots is more than compensated by the lack of any memory allocations. Even more so as the array API is 1:1 identical with the map's for the use-case at hand. Saves 1.2KiB in text size on optimized Linux AMD64 GCC 9.1 builds. Change-Id: I1bfa115ac75e2f7d9a4bd9a0e3f3241bf68c9989 Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qinputdevicemanager_p_p.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/gui/kernel/qinputdevicemanager_p_p.h') diff --git a/src/gui/kernel/qinputdevicemanager_p_p.h b/src/gui/kernel/qinputdevicemanager_p_p.h index 0a91252fbc..871f9315c3 100644 --- a/src/gui/kernel/qinputdevicemanager_p_p.h +++ b/src/gui/kernel/qinputdevicemanager_p_p.h @@ -52,10 +52,11 @@ // #include -#include #include #include "qinputdevicemanager_p.h" +#include + QT_BEGIN_NAMESPACE class Q_GUI_EXPORT QInputDeviceManagerPrivate : public QObjectPrivate @@ -68,7 +69,7 @@ public: int deviceCount(QInputDeviceManager::DeviceType type) const; void setDeviceCount(QInputDeviceManager::DeviceType type, int count); - QMap m_deviceCount; + std::array m_deviceCount; Qt::KeyboardModifiers keyboardModifiers; }; -- cgit v1.2.3