summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qinputdevicemanager_p_p.h
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2019-06-05 21:59:46 +0200
committerMarc Mutz <marc.mutz@kdab.com>2019-06-06 08:23:02 +0200
commitcbc9d8947842b97f28e3acb2d87d80b4861d00b9 (patch)
tree726d9ebfb0235287d25dfbe45f64d10a8e9ed306 /src/gui/kernel/qinputdevicemanager_p_p.h
parent3619e87ba1c0b11b8406fee3e1fe5c1e96abb7ef (diff)
QInputDeviceManager: replace a QMap<enum,int> with a std::array<int,#enum-values>
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ø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/gui/kernel/qinputdevicemanager_p_p.h')
-rw-r--r--src/gui/kernel/qinputdevicemanager_p_p.h5
1 files changed, 3 insertions, 2 deletions
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 <QtGui/private/qtguiglobal_p.h>
-#include <QtCore/qmap.h>
#include <private/qobject_p.h>
#include "qinputdevicemanager_p.h"
+#include <array>
+
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<QInputDeviceManager::DeviceType, int> m_deviceCount;
+ std::array<int, QInputDeviceManager::NumDeviceTypes> m_deviceCount;
Qt::KeyboardModifiers keyboardModifiers;
};