diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2019-06-05 21:59:46 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2019-06-06 08:23:02 +0200 |
commit | cbc9d8947842b97f28e3acb2d87d80b4861d00b9 (patch) | |
tree | 726d9ebfb0235287d25dfbe45f64d10a8e9ed306 /src/gui/kernel/qinputdevicemanager.cpp | |
parent | 3619e87ba1c0b11b8406fee3e1fe5c1e96abb7ef (diff) | |
download | qtbase-cbc9d8947842b97f28e3acb2d87d80b4861d00b9.tar.gz |
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.cpp')
-rw-r--r-- | src/gui/kernel/qinputdevicemanager.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/gui/kernel/qinputdevicemanager.cpp b/src/gui/kernel/qinputdevicemanager.cpp index 6e4e5a9c93..11442407e1 100644 --- a/src/gui/kernel/qinputdevicemanager.cpp +++ b/src/gui/kernel/qinputdevicemanager.cpp @@ -75,13 +75,13 @@ int QInputDeviceManager::deviceCount(DeviceType type) const int QInputDeviceManagerPrivate::deviceCount(QInputDeviceManager::DeviceType type) const { - return m_deviceCount.value(type); + return m_deviceCount[type]; } void QInputDeviceManagerPrivate::setDeviceCount(QInputDeviceManager::DeviceType type, int count) { Q_Q(QInputDeviceManager); - if (m_deviceCount.value(type) != count) { + if (m_deviceCount[type] != count) { m_deviceCount[type] = count; emit q->deviceListChanged(type); } |