From 8d6c18076f3268a6c85c6085d29f898267028101 Mon Sep 17 00:00:00 2001 From: Tom Englund Date: Mon, 26 Aug 2024 17:25:39 +0200 Subject: core: make most for loops use const references (#7527) why not let the compiler optimise things for us at hyprspeeds when we can. --- src/managers/SeatManager.cpp | 70 ++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 35 deletions(-) (limited to 'src/managers/SeatManager.cpp') diff --git a/src/managers/SeatManager.cpp b/src/managers/SeatManager.cpp index 801ae55a..e296dcc8 100644 --- a/src/managers/SeatManager.cpp +++ b/src/managers/SeatManager.cpp @@ -24,7 +24,7 @@ void CSeatManager::onNewSeatResource(SP resource) { } SP CSeatManager::containerForResource(SP seatResource) { - for (auto& c : seatResources) { + for (auto const& c : seatResources) { if (c->resource == seatResource) return c; } @@ -112,11 +112,11 @@ void CSeatManager::setKeyboardFocus(SP surf) { if (state.keyboardFocusResource) { auto client = state.keyboardFocusResource->client(); - for (auto& s : seatResources) { + for (auto const& s : seatResources) { if (s->resource->client() != client) continue; - for (auto& k : s->resource->keyboards) { + for (auto const& k : s->resource->keyboards) { if (!k) continue; @@ -134,12 +134,12 @@ void CSeatManager::setKeyboardFocus(SP surf) { } auto client = surf->client(); - for (auto& r : seatResources | std::views::reverse) { + for (auto const& r : seatResources | std::views::reverse) { if (r->resource->client() != client) continue; state.keyboardFocusResource = r->resource; - for (auto& k : r->resource->keyboards) { + for (auto const& k : r->resource->keyboards) { if (!k) continue; @@ -157,11 +157,11 @@ void CSeatManager::sendKeyboardKey(uint32_t timeMs, uint32_t key, wl_keyboard_ke if (!state.keyboardFocusResource) return; - for (auto& s : seatResources) { + for (auto const& s : seatResources) { if (s->resource->client() != state.keyboardFocusResource->client()) continue; - for (auto& k : s->resource->keyboards) { + for (auto const& k : s->resource->keyboards) { if (!k) continue; @@ -174,11 +174,11 @@ void CSeatManager::sendKeyboardMods(uint32_t depressed, uint32_t latched, uint32 if (!state.keyboardFocusResource) return; - for (auto& s : seatResources) { + for (auto const& s : seatResources) { if (s->resource->client() != state.keyboardFocusResource->client()) continue; - for (auto& k : s->resource->keyboards) { + for (auto const& k : s->resource->keyboards) { if (!k) continue; @@ -205,11 +205,11 @@ void CSeatManager::setPointerFocus(SP surf, const Vector2D& if (state.pointerFocusResource) { auto client = state.pointerFocusResource->client(); - for (auto& s : seatResources) { + for (auto const& s : seatResources) { if (s->resource->client() != client) continue; - for (auto& p : s->resource->pointers) { + for (auto const& p : s->resource->pointers) { if (!p) continue; @@ -230,12 +230,12 @@ void CSeatManager::setPointerFocus(SP surf, const Vector2D& } auto client = surf->client(); - for (auto& r : seatResources | std::views::reverse) { + for (auto const& r : seatResources | std::views::reverse) { if (r->resource->client() != client) continue; state.pointerFocusResource = r->resource; - for (auto& p : r->resource->pointers) { + for (auto const& p : r->resource->pointers) { if (!p) continue; @@ -257,11 +257,11 @@ void CSeatManager::sendPointerMotion(uint32_t timeMs, const Vector2D& local) { if (!state.pointerFocusResource) return; - for (auto& s : seatResources) { + for (auto const& s : seatResources) { if (s->resource->client() != state.pointerFocusResource->client()) continue; - for (auto& p : s->resource->pointers) { + for (auto const& p : s->resource->pointers) { if (!p) continue; @@ -276,11 +276,11 @@ void CSeatManager::sendPointerButton(uint32_t timeMs, uint32_t key, wl_pointer_b if (!state.pointerFocusResource) return; - for (auto& s : seatResources) { + for (auto const& s : seatResources) { if (s->resource->client() != state.pointerFocusResource->client()) continue; - for (auto& p : s->resource->pointers) { + for (auto const& p : s->resource->pointers) { if (!p) continue; @@ -300,11 +300,11 @@ void CSeatManager::sendPointerFrame(WP pResource) { if (!pResource) return; - for (auto& s : seatResources) { + for (auto const& s : seatResources) { if (s->resource->client() != pResource->client()) continue; - for (auto& p : s->resource->pointers) { + for (auto const& p : s->resource->pointers) { if (!p) continue; @@ -318,11 +318,11 @@ void CSeatManager::sendPointerAxis(uint32_t timeMs, wl_pointer_axis axis, double if (!state.pointerFocusResource) return; - for (auto& s : seatResources) { + for (auto const& s : seatResources) { if (s->resource->client() != state.pointerFocusResource->client()) continue; - for (auto& p : s->resource->pointers) { + for (auto const& p : s->resource->pointers) { if (!p) continue; @@ -346,12 +346,12 @@ void CSeatManager::sendTouchDown(SP surf, uint32_t timeMs, i state.touchFocus = surf; auto client = surf->client(); - for (auto& r : seatResources | std::views::reverse) { + for (auto const& r : seatResources | std::views::reverse) { if (r->resource->client() != client) continue; state.touchFocusResource = r->resource; - for (auto& t : r->resource->touches) { + for (auto const& t : r->resource->touches) { if (!t) continue; @@ -372,12 +372,12 @@ void CSeatManager::sendTouchUp(uint32_t timeMs, int32_t id) { return; auto client = state.touchFocusResource->client(); - for (auto& r : seatResources | std::views::reverse) { + for (auto const& r : seatResources | std::views::reverse) { if (r->resource->client() != client) continue; state.touchFocusResource = r->resource; - for (auto& t : r->resource->touches) { + for (auto const& t : r->resource->touches) { if (!t) continue; @@ -395,11 +395,11 @@ void CSeatManager::sendTouchMotion(uint32_t timeMs, int32_t id, const Vector2D& if (!state.touchFocusResource) return; - for (auto& s : seatResources) { + for (auto const& s : seatResources) { if (s->resource->client() != state.touchFocusResource->client()) continue; - for (auto& t : s->resource->touches) { + for (auto const& t : s->resource->touches) { if (!t) continue; @@ -412,11 +412,11 @@ void CSeatManager::sendTouchFrame() { if (!state.touchFocusResource) return; - for (auto& s : seatResources) { + for (auto const& s : seatResources) { if (s->resource->client() != state.touchFocusResource->client()) continue; - for (auto& t : s->resource->touches) { + for (auto const& t : s->resource->touches) { if (!t) continue; @@ -429,11 +429,11 @@ void CSeatManager::sendTouchCancel() { if (!state.touchFocusResource) return; - for (auto& s : seatResources) { + for (auto const& s : seatResources) { if (s->resource->client() != state.touchFocusResource->client()) continue; - for (auto& t : s->resource->touches) { + for (auto const& t : s->resource->touches) { if (!t) continue; @@ -446,11 +446,11 @@ void CSeatManager::sendTouchShape(int32_t id, const Vector2D& shape) { if (!state.touchFocusResource) return; - for (auto& s : seatResources) { + for (auto const& s : seatResources) { if (s->resource->client() != state.touchFocusResource->client()) continue; - for (auto& t : s->resource->touches) { + for (auto const& t : s->resource->touches) { if (!t) continue; @@ -463,11 +463,11 @@ void CSeatManager::sendTouchOrientation(int32_t id, double angle) { if (!state.touchFocusResource) return; - for (auto& s : seatResources) { + for (auto const& s : seatResources) { if (s->resource->client() != state.touchFocusResource->client()) continue; - for (auto& t : s->resource->touches) { + for (auto const& t : s->resource->touches) { if (!t) continue; -- cgit v1.2.3