diff options
| author | vaxerski <vaxry@vaxry.net> | 2025-01-17 18:21:34 +0100 |
|---|---|---|
| committer | vaxerski <vaxry@vaxry.net> | 2025-01-17 18:56:39 +0100 |
| commit | b7a3c4526990d6601ff2cac748ff860cda6bc16d (patch) | |
| tree | 425c6afa0bc35f7f370a666bd7a81214a6e9475a /src/protocols/ForeignToplevel.cpp | |
| parent | 2bad73354a5dbb9be8ba9a39b6238017a216a25b (diff) | |
core: add LIKELY and UNLIKELY macros
helps the compiler optimize
Diffstat (limited to 'src/protocols/ForeignToplevel.cpp')
| -rw-r--r-- | src/protocols/ForeignToplevel.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/protocols/ForeignToplevel.cpp b/src/protocols/ForeignToplevel.cpp index f6513a1d..6880164f 100644 --- a/src/protocols/ForeignToplevel.cpp +++ b/src/protocols/ForeignToplevel.cpp @@ -3,7 +3,7 @@ #include "../managers/HookSystemManager.hpp" CForeignToplevelHandle::CForeignToplevelHandle(SP<CExtForeignToplevelHandleV1> resource_, PHLWINDOW pWindow_) : resource(resource_), pWindow(pWindow_) { - if (!resource_->resource()) + if UNLIKELY (!resource_->resource()) return; resource->setOnDestroy([this](CExtForeignToplevelHandleV1* h) { PROTO::foreignToplevel->destroyHandle(this); }); @@ -19,7 +19,7 @@ PHLWINDOW CForeignToplevelHandle::window() { } CForeignToplevelList::CForeignToplevelList(SP<CExtForeignToplevelListV1> resource_) : resource(resource_) { - if (!resource_->resource()) + if UNLIKELY (!resource_->resource()) return; resource->setOnDestroy([this](CExtForeignToplevelListV1* h) { PROTO::foreignToplevel->onManagerResourceDestroy(this); }); @@ -40,7 +40,7 @@ CForeignToplevelList::CForeignToplevelList(SP<CExtForeignToplevelListV1> resourc } void CForeignToplevelList::onMap(PHLWINDOW pWindow) { - if (finished) + if UNLIKELY (finished) return; const auto NEWHANDLE = PROTO::foreignToplevel->m_vHandles.emplace_back( @@ -72,11 +72,11 @@ SP<CForeignToplevelHandle> CForeignToplevelList::handleForWindow(PHLWINDOW pWind } void CForeignToplevelList::onTitle(PHLWINDOW pWindow) { - if (finished) + if UNLIKELY (finished) return; const auto H = handleForWindow(pWindow); - if (!H || H->closed) + if UNLIKELY (!H || H->closed) return; H->resource->sendTitle(pWindow->m_szTitle.c_str()); @@ -84,11 +84,11 @@ void CForeignToplevelList::onTitle(PHLWINDOW pWindow) { } void CForeignToplevelList::onClass(PHLWINDOW pWindow) { - if (finished) + if UNLIKELY (finished) return; const auto H = handleForWindow(pWindow); - if (!H || H->closed) + if UNLIKELY (!H || H->closed) return; H->resource->sendAppId(pWindow->m_szClass.c_str()); @@ -96,11 +96,11 @@ void CForeignToplevelList::onClass(PHLWINDOW pWindow) { } void CForeignToplevelList::onUnmap(PHLWINDOW pWindow) { - if (finished) + if UNLIKELY (finished) return; const auto H = handleForWindow(pWindow); - if (!H) + if UNLIKELY (!H) return; H->resource->sendClosed(); @@ -149,7 +149,7 @@ CForeignToplevelProtocol::CForeignToplevelProtocol(const wl_interface* iface, co void CForeignToplevelProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { const auto RESOURCE = m_vManagers.emplace_back(std::make_unique<CForeignToplevelList>(makeShared<CExtForeignToplevelListV1>(client, ver, id))).get(); - if (!RESOURCE->good()) { + if UNLIKELY (!RESOURCE->good()) { LOGM(ERR, "Couldn't create a foreign list"); wl_client_post_no_memory(client); m_vManagers.pop_back(); |
