misc: constify the remaining for loops (#7534)

now we roll loops at blazing constified speed.
This commit is contained in:
Tom Englund 2024-08-26 20:24:30 +02:00 committed by GitHub
parent 1ea47950f4
commit 72c7818ae6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
79 changed files with 472 additions and 472 deletions

View file

@ -70,7 +70,7 @@ void CAnimationManager::tick() {
std::vector<CBaseAnimatedVariable*> animationEndedVars;
for (auto& av : m_vActiveAnimatedVariables) {
for (auto const& av : m_vActiveAnimatedVariables) {
if (av->m_eDamagePolicy == AVARDAMAGE_SHADOW && !*PSHADOWSENABLED) {
av->warp(false);
@ -113,7 +113,7 @@ void CAnimationManager::tick() {
g_pHyprRenderer->damageMonitor(PMONITOR);
// TODO: just make this into a damn callback already vax...
for (auto& w : g_pCompositor->m_vWindows) {
for (auto const& w : g_pCompositor->m_vWindows) {
if (!w->m_bIsMapped || w->isHidden() || w->m_pWorkspace != PWORKSPACE)
continue;
@ -214,7 +214,7 @@ void CAnimationManager::tick() {
PWINDOW->updateWindowDecos();
g_pHyprRenderer->damageWindow(PWINDOW);
} else if (PWORKSPACE) {
for (auto& w : g_pCompositor->m_vWindows) {
for (auto const& w : g_pCompositor->m_vWindows) {
if (!validMapped(w) || w->m_pWorkspace != PWORKSPACE)
continue;
@ -263,7 +263,7 @@ void CAnimationManager::tick() {
}
// do it here, because if this alters the animation vars deque we would be in trouble above.
for (auto& ave : animationEndedVars) {
for (auto const& ave : animationEndedVars) {
ave->onAnimationEnd();
}
}
@ -293,7 +293,7 @@ bool CAnimationManager::deltazero(const CColor& a, const CColor& b) {
}
bool CAnimationManager::bezierExists(const std::string& bezier) {
for (auto& [bc, bz] : m_mBezierCurves) {
for (auto const& [bc, bz] : m_mBezierCurves) {
if (bc == bezier)
return true;
}

View file

@ -193,7 +193,7 @@ void CCursorManager::setCursorFromName(const std::string& name) {
// fallback to a default if available
constexpr const std::array<const char*, 3> fallbackShapes = {"default", "left_ptr", "left-ptr"};
for (auto& s : fallbackShapes) {
for (auto const& s : fallbackShapes) {
m_sCurrentCursorShapeData = m_pHyprcursor->getShape(s, m_sCurrentStyleInfo);
if (m_sCurrentCursorShapeData.images.size() > 0)
@ -288,7 +288,7 @@ void CCursorManager::updateTheme() {
static auto PUSEHYPRCURSOR = CConfigValue<Hyprlang::INT>("cursor:enable_hyprcursor");
float highestScale = 1.0;
for (auto& m : g_pCompositor->m_vMonitors) {
for (auto const& m : g_pCompositor->m_vMonitors) {
if (m->scale > highestScale)
highestScale = m->scale;
}
@ -307,7 +307,7 @@ void CCursorManager::updateTheme() {
setCursorFromName("left_ptr");
for (auto& m : g_pCompositor->m_vMonitors) {
for (auto const& m : g_pCompositor->m_vMonitors) {
m->forceFullFrames = 5;
g_pCompositor->scheduleFrameForMonitor(m.get(), Aquamarine::IOutput::AQ_SCHEDULE_CURSOR_SHAPE);
}

View file

@ -30,7 +30,7 @@ void CHookSystemManager::emit(std::vector<SCallbackFNPtr>* const callbacks, SCal
std::vector<HANDLE> faultyHandles;
volatile bool needsDeadCleanup = false;
for (auto& cb : *callbacks) {
for (auto const& cb : *callbacks) {
m_bCurrentEventPlugin = false;
@ -70,7 +70,7 @@ void CHookSystemManager::emit(std::vector<SCallbackFNPtr>* const callbacks, SCal
std::erase_if(*callbacks, [](const auto& fn) { return !fn.fn.lock(); });
if (!faultyHandles.empty()) {
for (auto& h : faultyHandles)
for (auto const& h : faultyHandles)
g_pPluginSystem->unloadPlugin(g_pPluginSystem->getPluginByHandle(h), true);
}
}

View file

@ -908,7 +908,7 @@ uint64_t CKeybindManager::spawnRawProc(std::string args) {
grandchild = fork();
if (grandchild == 0) {
// run in grandchild
for (auto& e : HLENV) {
for (auto const& e : HLENV) {
setenv(e.first.c_str(), e.second.c_str(), 1);
}
setenv("WAYLAND_DISPLAY", g_pCompositor->m_szWLDisplaySocket.c_str(), 1);
@ -1720,10 +1720,10 @@ SDispatchResult CKeybindManager::workspaceOpt(std::string args) {
// we make a copy because changeWindowFloatingMode might invalidate the iterator
std::deque<PHLWINDOW> ptrs;
for (auto& w : g_pCompositor->m_vWindows)
for (auto const& w : g_pCompositor->m_vWindows)
ptrs.push_back(w);
for (auto& w : ptrs) {
for (auto const& w : ptrs) {
if (!w->m_bIsMapped || w->m_pWorkspace != PWORKSPACE || w->isHidden())
continue;
@ -1895,7 +1895,7 @@ SDispatchResult CKeybindManager::toggleSpecialWorkspace(std::string args) {
const auto PMONITOR = g_pCompositor->m_pLastMonitor;
auto specialOpenOnMonitor = PMONITOR->activeSpecialWorkspaceID();
for (auto& m : g_pCompositor->m_vMonitors) {
for (auto const& m : g_pCompositor->m_vMonitors) {
if (m->activeSpecialWorkspaceID() == workspaceID) {
requestedWorkspaceIsAlreadyOpen = true;
break;
@ -1922,7 +1922,7 @@ SDispatchResult CKeybindManager::toggleSpecialWorkspace(std::string args) {
SDispatchResult CKeybindManager::forceRendererReload(std::string args) {
bool overAgain = false;
for (auto& m : g_pCompositor->m_vMonitors) {
for (auto const& m : g_pCompositor->m_vMonitors) {
if (!m->output)
continue;
@ -2390,7 +2390,7 @@ SDispatchResult CKeybindManager::dpms(std::string arg) {
if (arg.find_first_of(' ') != std::string::npos)
port = arg.substr(arg.find_first_of(' ') + 1);
for (auto& m : g_pCompositor->m_vMonitors) {
for (auto const& m : g_pCompositor->m_vMonitors) {
if (!port.empty() && m->szName != port)
continue;

View file

@ -76,14 +76,14 @@ void CPointerManager::checkDefaultCursorWarp(SP<CMonitor> monitor, std::string m
}
void CPointerManager::lockSoftwareAll() {
for (auto& state : monitorStates)
for (auto const& state : monitorStates)
state->softwareLocks++;
updateCursorBackend();
}
void CPointerManager::unlockSoftwareAll() {
for (auto& state : monitorStates)
for (auto const& state : monitorStates)
state->softwareLocks--;
updateCursorBackend();
@ -261,7 +261,7 @@ void CPointerManager::resetCursorImage(bool apply) {
damageIfSoftware();
if (currentCursorImage.surface) {
for (auto& m : g_pCompositor->m_vMonitors) {
for (auto const& m : g_pCompositor->m_vMonitors) {
currentCursorImage.surface->resource()->leave(m);
}
@ -306,7 +306,7 @@ void CPointerManager::resetCursorImage(bool apply) {
void CPointerManager::updateCursorBackend() {
static auto PNOHW = CConfigValue<Hyprlang::INT>("cursor:no_hardware_cursors");
for (auto& m : g_pCompositor->m_vMonitors) {
for (auto const& m : g_pCompositor->m_vMonitors) {
auto state = stateFor(m);
if (!m->m_bEnabled || !m->dpmsStatus) {
@ -600,7 +600,7 @@ Vector2D CPointerManager::closestValid(const Vector2D& pos) {
//
static auto INSIDE_LAYOUT = [this](const CBox& box) -> bool {
for (auto& b : currentMonitorLayout.monitorBoxes) {
for (auto const& b : currentMonitorLayout.monitorBoxes) {
if (box.inside(b))
return true;
}
@ -608,7 +608,7 @@ Vector2D CPointerManager::closestValid(const Vector2D& pos) {
};
static auto INSIDE_LAYOUT_COORD = [this](const Vector2D& vec) -> bool {
for (auto& b : currentMonitorLayout.monitorBoxes) {
for (auto const& b : currentMonitorLayout.monitorBoxes) {
if (b.containsPoint(vec))
return true;
}
@ -619,7 +619,7 @@ Vector2D CPointerManager::closestValid(const Vector2D& pos) {
Vector2D leader;
float distanceSq = __FLT_MAX__;
for (auto& b : currentMonitorLayout.monitorBoxes) {
for (auto const& b : currentMonitorLayout.monitorBoxes) {
auto p = b.closestPoint(vec);
auto distSq = p.distanceSq(vec);
@ -673,7 +673,7 @@ void CPointerManager::damageIfSoftware() {
static auto PNOHW = CConfigValue<Hyprlang::INT>("cursor:no_hardware_cursors");
for (auto& mw : monitorStates) {
for (auto const& mw : monitorStates) {
if (mw->monitor.expired())
continue;
@ -748,7 +748,7 @@ void CPointerManager::warpAbsolute(Vector2D abs, SP<IHID> dev) {
if (POINTER->boundOutput == "entire") {
// find x and y size of the entire space
Vector2D bottomRight = {-9999999, -9999999}, topLeft = {9999999, 9999999};
for (auto& m : g_pCompositor->m_vMonitors) {
for (auto const& m : g_pCompositor->m_vMonitors) {
const auto EXTENT = m->logicalBox().extent();
const auto POS = m->logicalBox().pos();
if (EXTENT.x > bottomRight.x)
@ -787,7 +787,7 @@ void CPointerManager::warpAbsolute(Vector2D abs, SP<IHID> dev) {
void CPointerManager::onMonitorLayoutChange() {
currentMonitorLayout.monitorBoxes.clear();
for (auto& m : g_pCompositor->m_vMonitors) {
for (auto const& m : g_pCompositor->m_vMonitors) {
if (m->isMirror() || !m->m_bEnabled)
continue;

View file

@ -151,7 +151,7 @@ CProtocolManager::CProtocolManager() {
PROTO::toplevelExport = std::make_unique<CToplevelExportProtocol>(&hyprland_toplevel_export_manager_v1_interface, 2, "ToplevelExport");
PROTO::globalShortcuts = std::make_unique<CGlobalShortcutsProtocol>(&hyprland_global_shortcuts_manager_v1_interface, 1, "GlobalShortcuts");
for (auto& b : g_pCompositor->m_pAqBackend->getImplementations()) {
for (auto const& b : g_pCompositor->m_pAqBackend->getImplementations()) {
if (b->type() != Aquamarine::AQ_BACKEND_DRM)
continue;

View file

@ -483,7 +483,7 @@ void CSeatManager::refocusGrab() {
if (seatGrab->surfs.size() > 0) {
// try to find a surf in focus first
const auto MOUSE = g_pInputManager->getMouseCoordsInternal();
for (auto& s : seatGrab->surfs) {
for (auto const& s : seatGrab->surfs) {
auto hlSurf = CWLSurface::fromResource(s.lock());
if (!hlSurf)
continue;

View file

@ -67,7 +67,7 @@ void CSessionLockManager::onNewSessionLock(SP<CSessionLock> pLock) {
m_pSessionLock.reset();
g_pInputManager->refocus();
for (auto& m : g_pCompositor->m_vMonitors)
for (auto const& m : g_pCompositor->m_vMonitors)
g_pHyprRenderer->damageMonitor(m.get());
});
@ -75,7 +75,7 @@ void CSessionLockManager::onNewSessionLock(SP<CSessionLock> pLock) {
m_pSessionLock.reset();
g_pCompositor->focusSurface(nullptr);
for (auto& m : g_pCompositor->m_vMonitors)
for (auto const& m : g_pCompositor->m_vMonitors)
g_pHyprRenderer->damageMonitor(m.get());
});
@ -90,7 +90,7 @@ SSessionLockSurface* CSessionLockManager::getSessionLockSurfaceForMonitor(uint64
if (!m_pSessionLock)
return nullptr;
for (auto& sls : m_pSessionLock->vSessionLockSurfaces) {
for (auto const& sls : m_pSessionLock->vSessionLockSurfaces) {
if (sls->iMonitorID == id) {
if (sls->mapped)
return sls.get();

View file

@ -304,7 +304,7 @@ std::unordered_set<std::string> CXCursorManager::themePaths(std::string const& t
scanTheme(theme);
while (!inherits.empty()) {
auto oldInherits = inherits;
for (auto& i : oldInherits)
for (auto const& i : oldInherits)
scanTheme(i);
if (oldInherits.size() == inherits.size())

View file

@ -255,7 +255,7 @@ Vector2D CHyprXWaylandManager::xwaylandToWaylandCoords(const Vector2D& coord) {
CMonitor* pMonitor = nullptr;
double bestDistance = __FLT_MAX__;
for (auto& m : g_pCompositor->m_vMonitors) {
for (auto const& m : g_pCompositor->m_vMonitors) {
const auto SIZ = *PXWLFORCESCALEZERO ? m->vecTransformedSize : m->vecSize;
double distance =

View file

@ -19,7 +19,7 @@ CEventLoopManager::CEventLoopManager(wl_display* display, wl_event_loop* wlEvent
}
CEventLoopManager::~CEventLoopManager() {
for (auto& eventSource : m_sWayland.aqEventSources) {
for (auto const& eventSource : m_sWayland.aqEventSources) {
wl_event_source_remove(eventSource);
}
@ -46,7 +46,7 @@ void CEventLoopManager::enterLoop() {
m_sWayland.eventSource = wl_event_loop_add_fd(m_sWayland.loop, m_sTimers.timerfd, WL_EVENT_READABLE, timerWrite, nullptr);
aqPollFDs = g_pCompositor->m_pAqBackend->getPollFDs();
for (auto& fd : aqPollFDs) {
for (auto const& fd : aqPollFDs) {
m_sWayland.aqEventSources.emplace_back(wl_event_loop_add_fd(m_sWayland.loop, fd->fd, WL_EVENT_READABLE, aquamarineFDWrite, fd.get()));
}
@ -56,7 +56,7 @@ void CEventLoopManager::enterLoop() {
}
void CEventLoopManager::onTimerFire() {
for (auto& t : m_sTimers.timers) {
for (auto const& t : m_sTimers.timers) {
if (t.strongRef() > 1 /* if it's 1, it was lost. Don't call it. */ && t->passed() && !t->cancelled())
t->call(t);
}
@ -93,7 +93,7 @@ void CEventLoopManager::nudgeTimers() {
long nextTimerUs = 10 * 1000 * 1000; // 10s
for (auto& t : m_sTimers.timers) {
for (auto const& t : m_sTimers.timers) {
if (const auto µs = t->leftUs(); µs < nextTimerUs)
nextTimerUs = µs;
}
@ -122,7 +122,7 @@ void CEventLoopManager::doLater(const std::function<void()>& fn) {
auto cpy = IDLE->fns;
IDLE->fns.clear();
IDLE->eventSource = nullptr;
for (auto& c : cpy) {
for (auto const& c : cpy) {
if (c)
c();
}

View file

@ -49,7 +49,7 @@ void CInputManager::recheckIdleInhibitorStatus() {
}
// check manual user-set inhibitors
for (auto& w : g_pCompositor->m_vWindows) {
for (auto const& w : g_pCompositor->m_vWindows) {
if (w->m_eIdleInhibitMode == IDLEINHIBIT_NONE)
continue;

View file

@ -1033,7 +1033,7 @@ void CInputManager::setupMouse(SP<IPointer> mauz) {
}
void CInputManager::setPointerConfigs() {
for (auto& m : m_vPointers) {
for (auto const& m : m_vPointers) {
auto devname = m->hlName;
const auto HASCONFIG = g_pConfigManager->deviceConfigExists(devname);
@ -1268,7 +1268,7 @@ void CInputManager::updateKeyboardsLeds(SP<IKeyboard> pKeyboard) {
if (!leds.has_value())
return;
for (auto& k : m_vKeyboards) {
for (auto const& k : m_vKeyboards) {
k->updateLEDs(leds.value());
}
}
@ -1402,7 +1402,7 @@ void CInputManager::unconstrainMouse() {
if (g_pSeatManager->mouse.expired())
return;
for (auto& c : m_vConstraints) {
for (auto const& c : m_vConstraints) {
const auto C = c.lock();
if (!C)
@ -1416,7 +1416,7 @@ void CInputManager::unconstrainMouse() {
}
bool CInputManager::isConstrained() {
for (auto& c : m_vConstraints) {
for (auto const& c : m_vConstraints) {
const auto C = c.lock();
if (!C)
@ -1434,7 +1434,7 @@ bool CInputManager::isConstrained() {
void CInputManager::updateCapabilities() {
uint32_t caps = 0;
for (auto& h : m_vHIDs) {
for (auto const& h : m_vHIDs) {
if (h.expired())
continue;
@ -1449,7 +1449,7 @@ uint32_t CInputManager::accumulateModsFromAllKBs() {
uint32_t finalMask = 0;
for (auto& kb : m_vKeyboards) {
for (auto const& kb : m_vKeyboards) {
if (kb->isVirtual() && shouldIgnoreVirtualKeyboard(kb))
continue;
@ -1464,7 +1464,7 @@ uint32_t CInputManager::accumulateModsFromAllKBs() {
void CInputManager::disableAllKeyboards(bool virt) {
for (auto& k : m_vKeyboards) {
for (auto const& k : m_vKeyboards) {
if (k->isVirtual() != virt)
continue;
@ -1540,13 +1540,13 @@ void CInputManager::setTouchDeviceConfigs(SP<ITouch> dev) {
return;
}
for (auto& m : m_vTouches) {
for (auto const& m : m_vTouches) {
setConfig(m);
}
}
void CInputManager::setTabletConfigs() {
for (auto& t : m_vTablets) {
for (auto const& t : m_vTablets) {
if (t->aq()->getLibinputHandle()) {
const auto NAME = t->hlName;
const auto LIBINPUTDEV = t->aq()->getLibinputHandle();
@ -1711,7 +1711,7 @@ void CInputManager::setCursorIconOnBorder(PHLWINDOW w) {
bool onDeco = false;
for (auto& wd : w->m_dWindowDecorations) {
for (auto const& wd : w->m_dWindowDecorations) {
if (!(wd->getDecorationFlags() & DECORATION_ALLOWS_MOUSE_INPUT))
continue;

View file

@ -57,7 +57,7 @@ void CInputMethodRelay::onNewIME(SP<CInputMethodV2> pIME) {
if (!g_pCompositor->m_pLastFocus)
return;
for (auto& ti : m_vTextInputs) {
for (auto const& ti : m_vTextInputs) {
if (ti->client() != g_pCompositor->m_pLastFocus->client())
continue;
@ -80,7 +80,7 @@ CTextInput* CInputMethodRelay::getFocusedTextInput() {
if (!g_pCompositor->m_pLastFocus)
return nullptr;
for (auto& ti : m_vTextInputs) {
for (auto const& ti : m_vTextInputs) {
if (ti->focusedSurface() == g_pCompositor->m_pLastFocus)
return ti.get();
}
@ -101,7 +101,7 @@ void CInputMethodRelay::removeTextInput(CTextInput* pInput) {
}
void CInputMethodRelay::updateAllPopups() {
for (auto& p : m_vIMEPopups) {
for (auto const& p : m_vIMEPopups) {
p->onCommit();
}
}
@ -138,7 +138,7 @@ void CInputMethodRelay::onKeyboardFocus(SP<CWLSurfaceResource> pSurface) {
m_pLastKbFocus = pSurface;
for (auto& ti : m_vTextInputs) {
for (auto const& ti : m_vTextInputs) {
if (!ti->focusedSurface())
continue;
@ -148,7 +148,7 @@ void CInputMethodRelay::onKeyboardFocus(SP<CWLSurfaceResource> pSurface) {
if (!pSurface)
return;
for (auto& ti : m_vTextInputs) {
for (auto const& ti : m_vTextInputs) {
if (!ti->isV3())
continue;
@ -160,7 +160,7 @@ void CInputMethodRelay::onKeyboardFocus(SP<CWLSurfaceResource> pSurface) {
}
CInputPopup* CInputMethodRelay::popupFromCoords(const Vector2D& point) {
for (auto& p : m_vIMEPopups) {
for (auto const& p : m_vIMEPopups) {
if (p->isVecInPopup(point))
return p.get();
}
@ -169,7 +169,7 @@ CInputPopup* CInputMethodRelay::popupFromCoords(const Vector2D& point) {
}
CInputPopup* CInputMethodRelay::popupFromSurface(const SP<CWLSurfaceResource> surface) {
for (auto& p : m_vIMEPopups) {
for (auto const& p : m_vIMEPopups) {
if (p->getSurface() == surface)
return p.get();
}

View file

@ -229,7 +229,7 @@ void CInputManager::newTablet(SP<Aquamarine::ITablet> pDevice) {
SP<CTabletTool> CInputManager::ensureTabletToolPresent(SP<Aquamarine::ITabletTool> pTool) {
for (auto& t : m_vTabletTools) {
for (auto const& t : m_vTabletTools) {
if (t->aq() == pTool)
return t;
}