summaryrefslogtreecommitdiff
path: root/src/debug
diff options
context:
space:
mode:
authorKamikadze <40305144+Kam1k4dze@users.noreply.github.com>2025-05-30 18:25:59 +0500
committerGitHub <noreply@github.com>2025-05-30 14:25:59 +0100
commit9190443d951c21ab24201d033accf90b4d172f46 (patch)
tree28a5e4a1fa9c7424733ac7065a71cead7e141b6f /src/debug
parent9bf1b491440eac6f9c0d6853013ad5666c12d1d9 (diff)
refactor: use std::ranges whenever possible (#10584)
Diffstat (limited to 'src/debug')
-rw-r--r--src/debug/HyprCtl.cpp11
-rw-r--r--src/debug/HyprNotificationOverlay.cpp2
2 files changed, 6 insertions, 7 deletions
diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp
index adfbab1e..c8cc5c59 100644
--- a/src/debug/HyprCtl.cpp
+++ b/src/debug/HyprCtl.cpp
@@ -216,10 +216,10 @@ static std::string getTagsData(PHLWINDOW w, eHyprCtlOutputFormat format) {
const auto tags = w->m_tags.getTags();
if (format == eHyprCtlOutputFormat::FORMAT_JSON)
- return std::accumulate(tags.begin(), tags.end(), std::string(),
- [](const std::string& a, const std::string& b) { return a.empty() ? std::format("\"{}\"", b) : std::format("{}, \"{}\"", a, b); });
+ return std::ranges::fold_left(tags, std::string(),
+ [](const std::string& a, const std::string& b) { return a.empty() ? std::format("\"{}\"", b) : std::format("{}, \"{}\"", a, b); });
else
- return std::accumulate(tags.begin(), tags.end(), std::string(), [](const std::string& a, const std::string& b) { return a.empty() ? b : a + ", " + b; });
+ return std::ranges::fold_left(tags, std::string(), [](const std::string& a, const std::string& b) { return a.empty() ? b : a + ", " + b; });
}
static std::string getGroupedData(PHLWINDOW w, eHyprCtlOutputFormat format) {
@@ -921,7 +921,7 @@ static std::string bindsRequest(eHyprCtlOutputFormat format, std::string request
std::string versionRequest(eHyprCtlOutputFormat format, std::string request) {
auto commitMsg = trim(GIT_COMMIT_MESSAGE);
- std::replace(commitMsg.begin(), commitMsg.end(), '#', ' ');
+ std::ranges::replace(commitMsg, '#', ' ');
if (format == eHyprCtlOutputFormat::FORMAT_NORMAL) {
std::string result = std::format("Hyprland {} built from branch {} at commit {} {} ({}).\n"
@@ -1296,8 +1296,7 @@ static std::string switchXKBLayoutRequest(eHyprCtlOutputFormat format, std::stri
}
return result.empty() ? "ok" : result;
} else {
- auto k = std::find_if(g_pInputManager->m_keyboards.begin(), g_pInputManager->m_keyboards.end(),
- [&](const auto& other) { return other->m_hlName == g_pInputManager->deviceNameToInternalString(KB); });
+ auto k = std::ranges::find_if(g_pInputManager->m_keyboards, [&](const auto& other) { return other->m_hlName == g_pInputManager->deviceNameToInternalString(KB); });
if (k == g_pInputManager->m_keyboards.end())
return "device not found";
diff --git a/src/debug/HyprNotificationOverlay.cpp b/src/debug/HyprNotificationOverlay.cpp
index 4e17e797..bfa5c4e4 100644
--- a/src/debug/HyprNotificationOverlay.cpp
+++ b/src/debug/HyprNotificationOverlay.cpp
@@ -13,7 +13,7 @@ static inline auto iconBackendFromLayout(PangoLayout* layout) {
// preference: Nerd > FontAwesome > text
auto eIconBackendChecks = std::array<eIconBackend, 2>{ICONS_BACKEND_NF, ICONS_BACKEND_FA};
for (auto iconID : eIconBackendChecks) {
- auto iconsText = std::accumulate(ICONS_ARRAY[iconID].begin(), ICONS_ARRAY[iconID].end(), std::string());
+ auto iconsText = std::ranges::fold_left(ICONS_ARRAY[iconID], std::string(), std::plus<>());
pango_layout_set_text(layout, iconsText.c_str(), -1);
if (pango_layout_get_unknown_glyphs_count(layout) == 0)
return iconID;