summaryrefslogtreecommitdiff
path: root/src/protocols/LayerShell.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/LayerShell.cpp
parent2bad73354a5dbb9be8ba9a39b6238017a216a25b (diff)
core: add LIKELY and UNLIKELY macros
helps the compiler optimize
Diffstat (limited to 'src/protocols/LayerShell.cpp')
-rw-r--r--src/protocols/LayerShell.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/protocols/LayerShell.cpp b/src/protocols/LayerShell.cpp
index 0777149f..82d00a30 100644
--- a/src/protocols/LayerShell.cpp
+++ b/src/protocols/LayerShell.cpp
@@ -18,7 +18,7 @@ void CLayerShellResource::SState::reset() {
CLayerShellResource::CLayerShellResource(SP<CZwlrLayerSurfaceV1> resource_, SP<CWLSurfaceResource> surf_, std::string namespace_, PHLMONITOR pMonitor,
zwlrLayerShellV1Layer layer) : layerNamespace(namespace_), surface(surf_), resource(resource_) {
- if (!good())
+ if UNLIKELY (!good())
return;
current.layer = layer;
@@ -223,19 +223,19 @@ void CLayerShellProtocol::onGetLayerSurface(CZwlrLayerShellV1* pMgr, uint32_t id
const auto PMONITOR = output ? CWLOutputResource::fromResource(output)->monitor.lock() : nullptr;
auto SURF = CWLSurfaceResource::fromResource(surface);
- if (!SURF) {
+ if UNLIKELY (!SURF) {
pMgr->error(-1, "Invalid surface");
return;
}
- if (SURF->role->role() != SURFACE_ROLE_UNASSIGNED) {
+ if UNLIKELY (SURF->role->role() != SURFACE_ROLE_UNASSIGNED) {
pMgr->error(-1, "Surface already has a different role");
return;
}
const auto RESOURCE = m_vLayers.emplace_back(makeShared<CLayerShellResource>(makeShared<CZwlrLayerSurfaceV1>(CLIENT, pMgr->version(), id), SURF, namespace_, PMONITOR, layer));
- if (!RESOURCE->good()) {
+ if UNLIKELY (!RESOURCE->good()) {
pMgr->noMemory();
m_vLayers.pop_back();
return;