From 69c2b2926e128f1fd09080aed43944987a42026f Mon Sep 17 00:00:00 2001 From: Kamikadze <40305144+Kam1k4dze@users.noreply.github.com> Date: Sat, 31 May 2025 23:49:50 +0500 Subject: internal: refactor to use empty() (#10599) --- src/debug/HyprCtl.cpp | 8 ++++---- src/debug/HyprDebugOverlay.cpp | 8 ++++---- src/debug/HyprNotificationOverlay.cpp | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/debug') diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index c8cc5c59..77f54c2b 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -516,7 +516,7 @@ static std::string layersRequest(eHyprCtlOutputFormat format, std::string reques trimTrailingComma(result); - if (level.size() > 0) + if (!level.empty()) result += "\n "; result += "],"; @@ -1144,7 +1144,7 @@ static std::string dispatchKeyword(eHyprCtlOutputFormat format, std::string in) Debug::log(LOG, "Hyprctl: keyword {} : {}", COMMAND, VALUE); - if (retval == "") + if (retval.empty()) return "ok"; return retval; @@ -1528,7 +1528,7 @@ static std::string dispatchPlugin(eHyprCtlOutputFormat format, std::string reque if (format == eHyprCtlOutputFormat::FORMAT_JSON) { result += "["; - if (PLUGINS.size() == 0) + if (PLUGINS.empty()) return "[]"; for (auto const& p : PLUGINS) { @@ -1546,7 +1546,7 @@ static std::string dispatchPlugin(eHyprCtlOutputFormat format, std::string reque trimTrailingComma(result); result += "]"; } else { - if (PLUGINS.size() == 0) + if (PLUGINS.empty()) return "no plugins loaded"; for (auto const& p : PLUGINS) { diff --git a/src/debug/HyprDebugOverlay.cpp b/src/debug/HyprDebugOverlay.cpp index 332800dd..6c5d8000 100644 --- a/src/debug/HyprDebugOverlay.cpp +++ b/src/debug/HyprDebugOverlay.cpp @@ -83,7 +83,7 @@ int CHyprMonitorDebugOverlay::draw(int offset) { avgFrametime += ft; } float varFrametime = maxFrametime - minFrametime; - avgFrametime /= m_lastFrametimes.size() == 0 ? 1 : m_lastFrametimes.size(); + avgFrametime /= m_lastFrametimes.empty() ? 1 : m_lastFrametimes.size(); float avgRenderTime = 0; float maxRenderTime = 0; @@ -96,7 +96,7 @@ int CHyprMonitorDebugOverlay::draw(int offset) { avgRenderTime += rt; } float varRenderTime = maxRenderTime - minRenderTime; - avgRenderTime /= m_lastRenderTimes.size() == 0 ? 1 : m_lastRenderTimes.size(); + avgRenderTime /= m_lastRenderTimes.empty() ? 1 : m_lastRenderTimes.size(); float avgRenderTimeNoOverlay = 0; float maxRenderTimeNoOverlay = 0; @@ -109,7 +109,7 @@ int CHyprMonitorDebugOverlay::draw(int offset) { avgRenderTimeNoOverlay += rt; } float varRenderTimeNoOverlay = maxRenderTimeNoOverlay - minRenderTimeNoOverlay; - avgRenderTimeNoOverlay /= m_lastRenderTimes.size() == 0 ? 1 : m_lastRenderTimes.size(); + avgRenderTimeNoOverlay /= m_lastRenderTimes.empty() ? 1 : m_lastRenderTimes.size(); float avgAnimMgrTick = 0; float maxAnimMgrTick = 0; @@ -122,7 +122,7 @@ int CHyprMonitorDebugOverlay::draw(int offset) { avgAnimMgrTick += at; } float varAnimMgrTick = maxAnimMgrTick - minAnimMgrTick; - avgAnimMgrTick /= m_lastAnimationTicks.size() == 0 ? 1 : m_lastAnimationTicks.size(); + avgAnimMgrTick /= m_lastAnimationTicks.empty() ? 1 : m_lastAnimationTicks.size(); const float FPS = 1.f / (avgFrametime / 1000.f); // frametimes are in ms const float idealFPS = m_lastFrametimes.size(); diff --git a/src/debug/HyprNotificationOverlay.cpp b/src/debug/HyprNotificationOverlay.cpp index bfa5c4e4..c50abfe6 100644 --- a/src/debug/HyprNotificationOverlay.cpp +++ b/src/debug/HyprNotificationOverlay.cpp @@ -23,7 +23,7 @@ static inline auto iconBackendFromLayout(PangoLayout* layout) { CHyprNotificationOverlay::CHyprNotificationOverlay() { static auto P = g_pHookSystem->hookDynamic("focusedMon", [&](void* self, SCallbackInfo& info, std::any param) { - if (m_notifications.size() == 0) + if (m_notifications.empty()) return; g_pHyprRenderer->damageBox(m_lastDamage); @@ -210,7 +210,7 @@ void CHyprNotificationOverlay::draw(PHLMONITOR pMonitor) { } // Draw the notifications - if (m_notifications.size() == 0) + if (m_notifications.empty()) return; // Render to the monitor -- cgit v1.2.3