refactor: use std::ranges whenever possible (#10584)
This commit is contained in:
parent
9bf1b49144
commit
9190443d95
50 changed files with 137 additions and 146 deletions
|
|
@ -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";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue