core: make most for loops use const references (#7527)

why not let the compiler optimise things for us at hyprspeeds when we
can.
This commit is contained in:
Tom Englund
2024-08-26 17:25:39 +02:00
committed by GitHub
parent 9c5a37a797
commit 8d6c18076f
31 changed files with 169 additions and 169 deletions

View File

@@ -50,12 +50,12 @@ CDRMLeaseResource::CDRMLeaseResource(SP<CWpDrmLeaseV1> resource_, SP<CDRMLeaseRe
lease = aqlease;
for (auto& m : requested) {
for (auto const& m : requested) {
m->monitor->isBeingLeased = true;
}
listeners.destroyLease = lease->events.destroy.registerListener([this](std::any d) {
for (auto& m : requested) {
for (auto const& m : requested) {
if (m && m->monitor)
m->monitor->isBeingLeased = false;
}

View File

@@ -291,7 +291,7 @@ void CDataDeviceWLRProtocol::sendSelectionToDevice(SP<CWLRDataDevice> dev, SP<ID
}
void CDataDeviceWLRProtocol::setSelection(SP<IDataSource> source, bool primary) {
for (auto& o : m_vOffers) {
for (auto const& o : m_vOffers) {
if (o->source && o->source->hasDnd())
continue;
if (o->primary != primary)
@@ -302,7 +302,7 @@ void CDataDeviceWLRProtocol::setSelection(SP<IDataSource> source, bool primary)
if (!source) {
LOGM(LOG, "resetting {}selection", primary ? "primary " : " ");
for (auto& d : m_vDevices) {
for (auto const& d : m_vDevices) {
sendSelectionToDevice(d, nullptr, primary);
}
@@ -311,7 +311,7 @@ void CDataDeviceWLRProtocol::setSelection(SP<IDataSource> source, bool primary)
LOGM(LOG, "New {}selection for data source {:x}", primary ? "primary" : "", (uintptr_t)source.get());
for (auto& d : m_vDevices) {
for (auto const& d : m_vDevices) {
sendSelectionToDevice(d, source, primary);
}
}

View File

@@ -260,7 +260,7 @@ void CWLSurfaceResource::bfHelper(std::vector<SP<CWLSurfaceResource>> nodes, std
for (auto& n : nodes) {
std::erase_if(n->subsurfaces, [](const auto& e) { return e.expired(); });
// subsurfaces is sorted lowest -> highest
for (auto& c : n->subsurfaces) {
for (auto const& c : n->subsurfaces) {
if (c->zIndex >= 0)
break;
if (c->surface.expired())
@@ -274,7 +274,7 @@ void CWLSurfaceResource::bfHelper(std::vector<SP<CWLSurfaceResource>> nodes, std
nodes2.clear();
for (auto& n : nodes) {
for (auto const& n : nodes) {
Vector2D offset = {};
if (n->role->role() == SURFACE_ROLE_SUBSURFACE) {
auto subsurface = ((CSubsurfaceRole*)n->role.get())->subsurface.lock();
@@ -284,8 +284,8 @@ void CWLSurfaceResource::bfHelper(std::vector<SP<CWLSurfaceResource>> nodes, std
fn(n, offset, data);
}
for (auto& n : nodes) {
for (auto& c : n->subsurfaces) {
for (auto const& n : nodes) {
for (auto const& c : n->subsurfaces) {
if (c->zIndex < 0)
continue;
if (c->surface.expired())

View File

@@ -306,7 +306,7 @@ CWLDataDeviceManagerResource::CWLDataDeviceManagerResource(SP<CWlDataDeviceManag
RESOURCE->self = RESOURCE;
for (auto& s : sources) {
for (auto const& s : sources) {
if (!s)
continue;
s->device = RESOURCE;
@@ -390,7 +390,7 @@ void CWLDataDeviceProtocol::onDestroyDataSource(WP<CWLDataSourceResource> source
}
void CWLDataDeviceProtocol::setSelection(SP<IDataSource> source) {
for (auto& o : m_vOffers) {
for (auto const& o : m_vOffers) {
if (o->source && o->source->hasDnd())
continue;
o->dead = true;
@@ -439,7 +439,7 @@ void CWLDataDeviceProtocol::updateSelection() {
}
void CWLDataDeviceProtocol::onKeyboardFocus() {
for (auto& o : m_vOffers) {
for (auto const& o : m_vOffers) {
o->dead = true;
}
@@ -606,7 +606,7 @@ bool CWLDataDeviceProtocol::wasDragSuccessful() {
if (!dnd.focusedDevice || !dnd.currentSource)
return false;
for (auto& o : m_vOffers) {
for (auto const& o : m_vOffers) {
if (o->dead || !o->source || !o->source->hasDnd())
continue;

View File

@@ -118,7 +118,7 @@ bool CWLOutputProtocol::isDefunct() {
}
void CWLOutputProtocol::sendDone() {
for (auto& r : m_vOutputs) {
for (auto const& r : m_vOutputs) {
r->resource->sendDone();
}
}

View File

@@ -172,7 +172,7 @@ void CWLPointerResource::sendLeave() {
if (!PROTO::data->dndActive()) {
timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
for (auto& b : pressedButtons) {
for (auto const& b : pressedButtons) {
sendButton(now.tv_sec * 1000 + now.tv_nsec / 1000000, b, WL_POINTER_BUTTON_STATE_RELEASED);
}
}