From b7a3c4526990d6601ff2cac748ff860cda6bc16d Mon Sep 17 00:00:00 2001 From: vaxerski Date: Fri, 17 Jan 2025 18:21:34 +0100 Subject: core: add LIKELY and UNLIKELY macros helps the compiler optimize --- src/protocols/PointerGestures.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/protocols/PointerGestures.cpp') diff --git a/src/protocols/PointerGestures.cpp b/src/protocols/PointerGestures.cpp index 5dfb9d51..4df51b47 100644 --- a/src/protocols/PointerGestures.cpp +++ b/src/protocols/PointerGestures.cpp @@ -4,7 +4,7 @@ #include "core/Compositor.hpp" CPointerGestureSwipe::CPointerGestureSwipe(SP resource_) : resource(resource_) { - if (!resource->resource()) + if UNLIKELY (!resource->resource()) return; resource->setOnDestroy([this](CZwpPointerGestureSwipeV1* p) { PROTO::pointerGestures->onGestureDestroy(this); }); @@ -16,7 +16,7 @@ bool CPointerGestureSwipe::good() { } CPointerGestureHold::CPointerGestureHold(SP resource_) : resource(resource_) { - if (!resource->resource()) + if UNLIKELY (!resource->resource()) return; resource->setOnDestroy([this](CZwpPointerGestureHoldV1* p) { PROTO::pointerGestures->onGestureDestroy(this); }); @@ -28,7 +28,7 @@ bool CPointerGestureHold::good() { } CPointerGesturePinch::CPointerGesturePinch(SP resource_) : resource(resource_) { - if (!resource->resource()) + if UNLIKELY (!resource->resource()) return; resource->setOnDestroy([this](CZwpPointerGesturePinchV1* p) { PROTO::pointerGestures->onGestureDestroy(this); }); @@ -73,7 +73,7 @@ void CPointerGesturesProtocol::onGetPinchGesture(CZwpPointerGesturesV1* pMgr, ui const auto CLIENT = pMgr->client(); const auto RESOURCE = m_vPinches.emplace_back(std::make_unique(makeShared(CLIENT, pMgr->version(), id))).get(); - if (!RESOURCE->good()) { + if UNLIKELY (!RESOURCE->good()) { pMgr->noMemory(); LOGM(ERR, "Couldn't create gesture"); return; @@ -84,7 +84,7 @@ void CPointerGesturesProtocol::onGetSwipeGesture(CZwpPointerGesturesV1* pMgr, ui const auto CLIENT = pMgr->client(); const auto RESOURCE = m_vSwipes.emplace_back(std::make_unique(makeShared(CLIENT, pMgr->version(), id))).get(); - if (!RESOURCE->good()) { + if UNLIKELY (!RESOURCE->good()) { pMgr->noMemory(); LOGM(ERR, "Couldn't create gesture"); return; @@ -95,7 +95,7 @@ void CPointerGesturesProtocol::onGetHoldGesture(CZwpPointerGesturesV1* pMgr, uin const auto CLIENT = pMgr->client(); const auto RESOURCE = m_vHolds.emplace_back(std::make_unique(makeShared(CLIENT, pMgr->version(), id))).get(); - if (!RESOURCE->good()) { + if UNLIKELY (!RESOURCE->good()) { pMgr->noMemory(); LOGM(ERR, "Couldn't create gesture"); return; -- cgit v1.2.3