diff options
| author | Tom Englund <tomenglund26@gmail.com> | 2024-08-26 17:25:39 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-26 17:25:39 +0200 |
| commit | 8d6c18076f3268a6c85c6085d29f898267028101 (patch) | |
| tree | 9db19e850b0a3e2c5d20d5ca2ad5f9878eca89b1 /src/debug/HyprCtl.cpp | |
| parent | 9c5a37a797ea1f1829859ab5b07016b2f27f739c (diff) | |
core: make most for loops use const references (#7527)
why not let the compiler optimise things for us at hyprspeeds when we
can.
Diffstat (limited to 'src/debug/HyprCtl.cpp')
| -rw-r--r-- | src/debug/HyprCtl.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index a92c3a53..2fc5cc7d 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -146,7 +146,7 @@ std::string monitorsRequest(eHyprCtlOutputFormat format, std::string request) { if (format == eHyprCtlOutputFormat::FORMAT_JSON) { result += "["; - for (auto& m : allMonitors ? g_pCompositor->m_vRealMonitors : g_pCompositor->m_vMonitors) { + for (auto const& m : allMonitors ? g_pCompositor->m_vRealMonitors : g_pCompositor->m_vMonitors) { result += CHyprCtl::getMonitorData(m, format); } @@ -154,7 +154,7 @@ std::string monitorsRequest(eHyprCtlOutputFormat format, std::string request) { result += "]"; } else { - for (auto& m : allMonitors ? g_pCompositor->m_vRealMonitors : g_pCompositor->m_vMonitors) { + for (auto const& m : allMonitors ? g_pCompositor->m_vRealMonitors : g_pCompositor->m_vMonitors) { if (!m->output || m->ID == -1) continue; @@ -272,7 +272,7 @@ std::string clientsRequest(eHyprCtlOutputFormat format, std::string request) { if (format == eHyprCtlOutputFormat::FORMAT_JSON) { result += "["; - for (auto& w : g_pCompositor->m_vWindows) { + for (auto const& w : g_pCompositor->m_vWindows) { if (!w->m_bIsMapped && !g_pHyprCtl->m_sCurrentRequestParams.all) continue; @@ -283,7 +283,7 @@ std::string clientsRequest(eHyprCtlOutputFormat format, std::string request) { result += "]"; } else { - for (auto& w : g_pCompositor->m_vWindows) { + for (auto const& w : g_pCompositor->m_vWindows) { if (!w->m_bIsMapped && !g_pHyprCtl->m_sCurrentRequestParams.all) continue; @@ -381,7 +381,7 @@ std::string workspacesRequest(eHyprCtlOutputFormat format, std::string request) if (format == eHyprCtlOutputFormat::FORMAT_JSON) { result += "["; - for (auto& w : g_pCompositor->m_vWorkspaces) { + for (auto const& w : g_pCompositor->m_vWorkspaces) { result += CHyprCtl::getWorkspaceData(w, format); result += ","; } @@ -389,7 +389,7 @@ std::string workspacesRequest(eHyprCtlOutputFormat format, std::string request) trimTrailingComma(result); result += "]"; } else { - for (auto& w : g_pCompositor->m_vWorkspaces) { + for (auto const& w : g_pCompositor->m_vWorkspaces) { result += CHyprCtl::getWorkspaceData(w, format); } } @@ -401,7 +401,7 @@ std::string workspaceRulesRequest(eHyprCtlOutputFormat format, std::string reque std::string result = ""; if (format == eHyprCtlOutputFormat::FORMAT_JSON) { result += "["; - for (auto& r : g_pConfigManager->getAllWorkspaceRules()) { + for (auto const& r : g_pConfigManager->getAllWorkspaceRules()) { result += getWorkspaceRuleData(r, format); result += ","; } @@ -409,7 +409,7 @@ std::string workspaceRulesRequest(eHyprCtlOutputFormat format, std::string reque trimTrailingComma(result); result += "]"; } else { - for (auto& r : g_pConfigManager->getAllWorkspaceRules()) { + for (auto const& r : g_pConfigManager->getAllWorkspaceRules()) { result += getWorkspaceRuleData(r, format); } } @@ -437,7 +437,7 @@ std::string layersRequest(eHyprCtlOutputFormat format, std::string request) { if (format == eHyprCtlOutputFormat::FORMAT_JSON) { result += "{\n"; - for (auto& mon : g_pCompositor->m_vMonitors) { + for (auto const& mon : g_pCompositor->m_vMonitors) { result += std::format( R"#("{}": {{ "levels": {{ @@ -744,7 +744,7 @@ std::string animationsRequest(eHyprCtlOutputFormat format, std::string request) ret += ",\n["; - for (auto& bz : g_pAnimationManager->getAllBeziers()) { + for (auto const& bz : g_pAnimationManager->getAllBeziers()) { ret += std::format(R"#( {{ "name": "{}" @@ -782,7 +782,7 @@ std::string globalShortcutsRequest(eHyprCtlOutputFormat format, std::string requ ret += std::format("{}:{} -> {}\n", sh.appid, sh.id, sh.description); } else { ret += "["; - for (auto& sh : SHORTCUTS) { + for (auto const& sh : SHORTCUTS) { ret += std::format(R"#( {{ "name": "{}", @@ -1286,7 +1286,7 @@ std::string dispatchSetProp(eHyprCtlOutputFormat format, std::string request) { g_pCompositor->focusWindow(PLASTWINDOW); } - for (auto& m : g_pCompositor->m_vMonitors) + for (auto const& m : g_pCompositor->m_vMonitors) g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m->ID); return "ok"; @@ -1386,7 +1386,7 @@ std::string dispatchOutput(eHyprCtlOutputFormat format, std::string request) { bool added = false; if (!vars[3].empty()) { - for (auto& m : g_pCompositor->m_vRealMonitors) { + for (auto const& m : g_pCompositor->m_vRealMonitors) { if (m->szName == vars[3]) return "Name already taken"; } |
