diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2019-07-21 18:55:01 +0300 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2020-02-11 02:05:59 +0300 |
commit | 22ff39a5d92be69557ab3544ae36affaffc38c95 (patch) | |
tree | 953ed4fb5cc6d0fbdd6b84ee651131feb8a4b06d /src/client/qwaylandcursor.cpp | |
parent | 143367312e0a6b1389c44cf62ca70f133b99c7b1 (diff) |
QWaylandCursorTheme: replace a QMap with a C array
The QMap's key is an enumeration with small values (<= 33, as of this
writing), and while the range has a hole, it's not a terribly big one.
So, instead of using a QMap, just use a C array of mapped_type, using
the key as an index into the array. This gives a 'map' with zero
memory allocations.
It also saves a bit more than 700B in text size on optimized Linux
AMD64 GCC 9.1 builds.
Change-Id: If538ba80075f1bbdffd82b070e871391e6a5a6d1
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/client/qwaylandcursor.cpp')
-rw-r--r-- | src/client/qwaylandcursor.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/client/qwaylandcursor.cpp b/src/client/qwaylandcursor.cpp index 1d3d88bea..4d540c5db 100644 --- a/src/client/qwaylandcursor.cpp +++ b/src/client/qwaylandcursor.cpp @@ -74,7 +74,7 @@ QWaylandCursorTheme::~QWaylandCursorTheme() wl_cursor *QWaylandCursorTheme::requestCursor(WaylandCursor shape) { - if (struct wl_cursor *cursor = m_cursors.value(shape, nullptr)) + if (struct wl_cursor *cursor = m_cursors[shape]) return cursor; static Q_CONSTEXPR struct ShapeAndName { @@ -206,7 +206,7 @@ wl_cursor *QWaylandCursorTheme::requestCursor(WaylandCursor shape) ShapeAndName{shape, ""}, byShape); for (auto it = p.first; it != p.second; ++it) { if (wl_cursor *cursor = wl_cursor_theme_get_cursor(m_theme, it->name)) { - m_cursors.insert(shape, cursor); + m_cursors[shape] = cursor; return cursor; } } |