summaryrefslogtreecommitdiff
path: root/src/protocols/XWaylandShell.cpp
diff options
context:
space:
mode:
authorvaxerski <vaxry@vaxry.net>2025-01-17 18:21:34 +0100
committervaxerski <vaxry@vaxry.net>2025-01-17 18:56:39 +0100
commitb7a3c4526990d6601ff2cac748ff860cda6bc16d (patch)
tree425c6afa0bc35f7f370a666bd7a81214a6e9475a /src/protocols/XWaylandShell.cpp
parent2bad73354a5dbb9be8ba9a39b6238017a216a25b (diff)
core: add LIKELY and UNLIKELY macros
helps the compiler optimize
Diffstat (limited to 'src/protocols/XWaylandShell.cpp')
-rw-r--r--src/protocols/XWaylandShell.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/protocols/XWaylandShell.cpp b/src/protocols/XWaylandShell.cpp
index 81194163..b4615e19 100644
--- a/src/protocols/XWaylandShell.cpp
+++ b/src/protocols/XWaylandShell.cpp
@@ -3,7 +3,7 @@
#include <algorithm>
CXWaylandSurfaceResource::CXWaylandSurfaceResource(SP<CXwaylandSurfaceV1> resource_, SP<CWLSurfaceResource> surface_) : surface(surface_), resource(resource_) {
- if (!good())
+ if UNLIKELY (!good())
return;
resource->setDestroy([this](CXwaylandSurfaceV1* r) {
@@ -36,7 +36,7 @@ wl_client* CXWaylandSurfaceResource::client() {
}
CXWaylandShellResource::CXWaylandShellResource(SP<CXwaylandShellV1> resource_) : resource(resource_) {
- if (!good())
+ if UNLIKELY (!good())
return;
resource->setDestroy([this](CXwaylandShellV1* r) { PROTO::xwaylandShell->destroyResource(this); });
@@ -46,7 +46,7 @@ CXWaylandShellResource::CXWaylandShellResource(SP<CXwaylandShellV1> resource_) :
const auto RESOURCE = PROTO::xwaylandShell->m_vSurfaces.emplace_back(
makeShared<CXWaylandSurfaceResource>(makeShared<CXwaylandSurfaceV1>(r->client(), r->version(), id), CWLSurfaceResource::fromResource(surface)));
- if (!RESOURCE->good()) {
+ if UNLIKELY (!RESOURCE->good()) {
r->noMemory();
PROTO::xwaylandShell->m_vSurfaces.pop_back();
return;
@@ -67,7 +67,7 @@ CXWaylandShellProtocol::CXWaylandShellProtocol(const wl_interface* iface, const
void CXWaylandShellProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
const auto RESOURCE = m_vManagers.emplace_back(makeShared<CXWaylandShellResource>(makeShared<CXwaylandShellV1>(client, ver, id)));
- if (!RESOURCE->good()) {
+ if UNLIKELY (!RESOURCE->good()) {
wl_client_post_no_memory(client);
m_vManagers.pop_back();
return;