core: add LIKELY and UNLIKELY macros

helps the compiler optimize
This commit is contained in:
vaxerski 2025-01-17 18:21:34 +01:00
parent 2bad73354a
commit b7a3c45269
58 changed files with 395 additions and 396 deletions

View file

@ -17,11 +17,11 @@ CDMABuffer::CDMABuffer(uint32_t id, wl_client* client, Aquamarine::SDMABUFAttrs
auto eglImage = g_pHyprOpenGL->createEGLImage(attrs);
if (!eglImage) {
if UNLIKELY (!eglImage) {
Debug::log(ERR, "CDMABuffer: failed to import EGLImage, retrying as implicit");
attrs.modifier = DRM_FORMAT_MOD_INVALID;
eglImage = g_pHyprOpenGL->createEGLImage(attrs);
if (!eglImage) {
if UNLIKELY (!eglImage) {
Debug::log(ERR, "CDMABuffer: failed to import EGLImage");
return;
}
@ -31,7 +31,7 @@ CDMABuffer::CDMABuffer(uint32_t id, wl_client* client, Aquamarine::SDMABUFAttrs
opaque = NFormatUtils::isFormatOpaque(attrs.format);
success = texture->m_iTexID;
if (!success)
if UNLIKELY (!success)
Debug::log(ERR, "Failed to create a dmabuf: texture is null");
}

View file

@ -6,7 +6,7 @@
#include <xf86drm.h>
CWLBufferResource::CWLBufferResource(SP<CWlBuffer> resource_) : resource(resource_) {
if (!good())
if UNLIKELY (!good())
return;
resource->setOnDestroy([this](CWlBuffer* r) {