Skip to content

Commit

Permalink
use UNLIKELY
Browse files Browse the repository at this point in the history
  • Loading branch information
PaideiaDilemma committed Jan 19, 2025
1 parent 2a39449 commit 1fb430b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/protocols/LockNotify.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "LockNotify.hpp"

CHyprlandLockNotification::CHyprlandLockNotification(SP<CHyprlandLockNotificationV1> resource_) : m_resource(resource_) {
if (!m_resource->resource())
if UNLIKELY (!m_resource->resource())
return;

m_resource->setDestroy([this](CHyprlandLockNotificationV1* r) { PROTO::lockNotify->destroyNotification(this); });
Expand Down Expand Up @@ -50,19 +50,19 @@ void CLockNotifyProtocol::onGetNotification(CHyprlandLockNotifierV1* pMgr, uint3
const auto CLIENT = pMgr->client();
const auto RESOURCE = m_notifications.emplace_back(makeShared<CHyprlandLockNotification>(makeShared<CHyprlandLockNotificationV1>(CLIENT, pMgr->version(), id))).get();

if (!RESOURCE->good()) {
if UNLIKELY (!RESOURCE->good()) {
pMgr->noMemory();
m_notifications.pop_back();
return;
}

// Already locked?? Send locked right away
if (m_isLocked)
if UNLIKELY (m_isLocked)
m_notifications.back()->onLocked();
}

void CLockNotifyProtocol::onLocked() {
if (m_isLocked) {
if UNLIKELY (m_isLocked) {
LOGM(ERR, "Not sending lock notification. Already locked!");
return;
}
Expand All @@ -75,7 +75,7 @@ void CLockNotifyProtocol::onLocked() {
}

void CLockNotifyProtocol::onUnlocked() {
if (!m_isLocked) {
if UNLIKELY (!m_isLocked) {
LOGM(ERR, "Not sending unlock notification. Not locked!");
return;
}
Expand Down

0 comments on commit 1fb430b

Please sign in to comment.