internal: refactor to use empty() (#10599)

This commit is contained in:
Kamikadze 2025-05-31 23:49:50 +05:00 committed by GitHub
parent 4078e1d17c
commit 69c2b2926e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 57 additions and 57 deletions

View file

@ -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) {

View file

@ -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();

View file

@ -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