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/TextInputV1.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/protocols/TextInputV1.cpp') diff --git a/src/protocols/TextInputV1.cpp b/src/protocols/TextInputV1.cpp index b8eb5835..4bf5e9e1 100644 --- a/src/protocols/TextInputV1.cpp +++ b/src/protocols/TextInputV1.cpp @@ -7,13 +7,13 @@ CTextInputV1::~CTextInputV1() { } CTextInputV1::CTextInputV1(SP resource_) : resource(resource_) { - if (!good()) + if UNLIKELY (!good()) return; resource->setOnDestroy([this](CZwpTextInputV1* pMgr) { PROTO::textInputV1->destroyResource(this); }); resource->setActivate([this](CZwpTextInputV1* pMgr, wl_resource* seat, wl_resource* surface) { - if (!surface) { + if UNLIKELY (!surface) { LOGM(WARN, "Text-input-v1 PTI{:x}: No surface to activate text input on!", (uintptr_t)this); return; } @@ -105,7 +105,7 @@ void CTextInputV1Protocol::bindManager(wl_client* client, void* data, uint32_t v const auto PTI = m_vClients.emplace_back(makeShared(makeShared(pMgr->client(), pMgr->version(), id))); LOGM(LOG, "New TI V1 at {:x}", (uintptr_t)PTI.get()); - if (!PTI->good()) { + if UNLIKELY (!PTI->good()) { LOGM(ERR, "Could not alloc wl_resource for TIV1"); pMgr->noMemory(); PROTO::textInputV1->destroyResource(PTI.get()); -- cgit v1.2.3