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/CTMControl.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/protocols/CTMControl.cpp') diff --git a/src/protocols/CTMControl.cpp b/src/protocols/CTMControl.cpp index 91e05ac4..91f4501f 100644 --- a/src/protocols/CTMControl.cpp +++ b/src/protocols/CTMControl.cpp @@ -7,7 +7,7 @@ #include "../helpers/Monitor.hpp" CHyprlandCTMControlResource::CHyprlandCTMControlResource(SP resource_) : resource(resource_) { - if (!good()) + if UNLIKELY (!good()) return; resource->setDestroy([this](CHyprlandCtmControlManagerV1* pMgr) { PROTO::ctm->destroyResource(this); }); @@ -17,12 +17,12 @@ CHyprlandCTMControlResource::CHyprlandCTMControlResource(SPmonitor.lock(); - if (!PMONITOR) + if UNLIKELY (!PMONITOR) return; // ?!?! const std::array MAT = {wl_fixed_to_double(mat0), wl_fixed_to_double(mat1), wl_fixed_to_double(mat2), wl_fixed_to_double(mat3), wl_fixed_to_double(mat4), @@ -72,7 +72,7 @@ void CHyprlandCTMControlProtocol::bindManager(wl_client* client, void* data, uin const auto RESOURCE = m_vManagers.emplace_back(makeShared(makeShared(client, ver, id))); - if (!RESOURCE->good()) { + if UNLIKELY (!RESOURCE->good()) { wl_client_post_no_memory(client); m_vManagers.pop_back(); return; -- cgit v1.2.3