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/ColorManagement.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src/protocols/ColorManagement.cpp') diff --git a/src/protocols/ColorManagement.cpp b/src/protocols/ColorManagement.cpp index a76e13c0..c2814361 100644 --- a/src/protocols/ColorManagement.cpp +++ b/src/protocols/ColorManagement.cpp @@ -2,7 +2,7 @@ #include "Compositor.hpp" CColorManager::CColorManager(SP resource_) : resource(resource_) { - if (!good()) + if UNLIKELY (!good()) return; resource->sendSupportedFeature(XX_COLOR_MANAGER_V4_FEATURE_PARAMETRIC); @@ -38,7 +38,7 @@ CColorManager::CColorManager(SP resource_) : resource(resourc const auto RESOURCE = PROTO::colorManagement->m_vOutputs.emplace_back(makeShared(makeShared(r->client(), r->version(), id))); - if (!RESOURCE->good()) { + if UNLIKELY (!RESOURCE->good()) { r->noMemory(); PROTO::colorManagement->m_vOutputs.pop_back(); return; @@ -63,7 +63,7 @@ CColorManager::CColorManager(SP resource_) : resource(resourc const auto RESOURCE = PROTO::colorManagement->m_vSurfaces.emplace_back(makeShared(makeShared(r->client(), r->version(), id), SURF)); - if (!RESOURCE->good()) { + if UNLIKELY (!RESOURCE->good()) { r->noMemory(); PROTO::colorManagement->m_vSurfaces.pop_back(); return; @@ -86,7 +86,7 @@ CColorManager::CColorManager(SP resource_) : resource(resourc const auto RESOURCE = PROTO::colorManagement->m_vFeedbackSurfaces.emplace_back( makeShared(makeShared(r->client(), r->version(), id), SURF)); - if (!RESOURCE->good()) { + if UNLIKELY (!RESOURCE->good()) { r->noMemory(); PROTO::colorManagement->m_vFeedbackSurfaces.pop_back(); return; @@ -104,7 +104,7 @@ CColorManager::CColorManager(SP resource_) : resource(resourc const auto RESOURCE = PROTO::colorManagement->m_vParametricCreators.emplace_back( makeShared(makeShared(r->client(), r->version(), id))); - if (!RESOURCE->good()) { + if UNLIKELY (!RESOURCE->good()) { r->noMemory(); PROTO::colorManagement->m_vParametricCreators.pop_back(); return; @@ -121,7 +121,7 @@ bool CColorManager::good() { } CColorManagementOutput::CColorManagementOutput(SP resource_) : resource(resource_) { - if (!good()) + if UNLIKELY (!good()) return; pClient = resource->client(); @@ -137,7 +137,7 @@ CColorManagementOutput::CColorManagementOutput(SP re const auto RESOURCE = PROTO::colorManagement->m_vImageDescriptions.emplace_back( makeShared(makeShared(r->client(), r->version(), id))); - if (!RESOURCE->good()) { + if UNLIKELY (!RESOURCE->good()) { r->noMemory(); PROTO::colorManagement->m_vImageDescriptions.pop_back(); return; @@ -160,7 +160,7 @@ CColorManagementSurface::CColorManagementSurface(SP surface_ } CColorManagementSurface::CColorManagementSurface(SP resource_, SP surface_) : surface(surface_), resource(resource_) { - if (!good()) + if UNLIKELY (!good()) return; pClient = resource->client(); @@ -242,7 +242,7 @@ bool CColorManagementSurface::needsHdrMetadataUpdate() { CColorManagementFeedbackSurface::CColorManagementFeedbackSurface(SP resource_, SP surface_) : surface(surface_), resource(resource_) { - if (!good()) + if UNLIKELY (!good()) return; pClient = resource->client(); @@ -269,7 +269,7 @@ CColorManagementFeedbackSurface::CColorManagementFeedbackSurface(SPm_vImageDescriptions.emplace_back( makeShared(makeShared(r->client(), r->version(), id), true)); - if (!RESOURCE->good()) { + if UNLIKELY (!RESOURCE->good()) { r->noMemory(); PROTO::colorManagement->m_vImageDescriptions.pop_back(); return; @@ -293,7 +293,7 @@ wl_client* CColorManagementFeedbackSurface::client() { } CColorManagementParametricCreator::CColorManagementParametricCreator(SP resource_) : resource(resource_) { - if (!good()) + if UNLIKELY (!good()) return; // pClient = resource->client(); @@ -318,7 +318,7 @@ CColorManagementParametricCreator::CColorManagementParametricCreator(SPm_vImageDescriptions.emplace_back( makeShared(makeShared(r->client(), r->version(), id))); - if (!RESOURCE->good()) { + if UNLIKELY (!RESOURCE->good()) { r->noMemory(); PROTO::colorManagement->m_vImageDescriptions.pop_back(); return; @@ -465,7 +465,7 @@ wl_client* CColorManagementParametricCreator::client() { CColorManagementImageDescription::CColorManagementImageDescription(SP resource_, bool allowGetInformation) : m_resource(resource_), m_allowGetInformation(allowGetInformation) { - if (!good()) + if UNLIKELY (!good()) return; pClient = m_resource->client(); @@ -482,7 +482,7 @@ CColorManagementImageDescription::CColorManagementImageDescription(SP(makeShared(r->client(), r->version(), id), settings); - if (!RESOURCE->good()) + if UNLIKELY (!RESOURCE->good()) r->noMemory(); // CColorManagementImageDescriptionInfo should send everything in the constructor and be ready for destroying at this point @@ -504,7 +504,7 @@ SP CColorManagementImageDescription::resource() { CColorManagementImageDescriptionInfo::CColorManagementImageDescriptionInfo(SP resource_, const SImageDescription& settings_) : m_resource(resource_), settings(settings_) { - if (!good()) + if UNLIKELY (!good()) return; pClient = m_resource->client(); @@ -549,7 +549,7 @@ CColorManagementProtocol::CColorManagementProtocol(const wl_interface* iface, co void CColorManagementProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { 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