From 7a2e6bb58e7f42221a744723ffecf00d950a4b2a Mon Sep 17 00:00:00 2001 From: Fushan Wen Date: Sun, 12 May 2024 09:51:44 +0800 Subject: [PATCH] Constify Qt containers passed to ranges This constifies a few mutable Qt containers passed to std::ranges to improve the efficiency. --- src/backends/libinput/connection.cpp | 4 ++-- src/backends/x11/windowed/x11_windowed_backend.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/backends/libinput/connection.cpp b/src/backends/libinput/connection.cpp index e49f7e6cb7..8d3c223369 100644 --- a/src/backends/libinput/connection.cpp +++ b/src/backends/libinput/connection.cpp @@ -287,10 +287,10 @@ void Connection::processEvents() break; } case LIBINPUT_EVENT_DEVICE_REMOVED: { - auto it = std::ranges::find_if(m_devices, [&event](Device *d) { + auto it = std::ranges::find_if(std::as_const(m_devices), [&event](Device *d) { return event->device() == d; }); - if (it == m_devices.end()) { + if (it == m_devices.cend()) { // we don't know this device break; } diff --git a/src/backends/x11/windowed/x11_windowed_backend.cpp b/src/backends/x11/windowed/x11_windowed_backend.cpp index 18e5e1e7d9..c8cf708f55 100644 --- a/src/backends/x11/windowed/x11_windowed_backend.cpp +++ b/src/backends/x11/windowed/x11_windowed_backend.cpp @@ -513,10 +513,10 @@ void X11WindowedBackend::updateWindowTitle() void X11WindowedBackend::handleClientMessage(xcb_client_message_event_t *event) { - auto it = std::ranges::find_if(m_outputs, [event](X11WindowedOutput *output) { + auto it = std::ranges::find_if(std::as_const(m_outputs), [event](X11WindowedOutput *output) { return output->window() == event->window; }); - if (it == m_outputs.end()) { + if (it == m_outputs.cend()) { return; } if (event->type == m_protocols && m_protocols != XCB_ATOM_NONE) {