summaryrefslogtreecommitdiff
path: root/src/protocols/GlobalShortcuts.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/GlobalShortcuts.cpp
parent2bad73354a5dbb9be8ba9a39b6238017a216a25b (diff)
core: add LIKELY and UNLIKELY macros
helps the compiler optimize
Diffstat (limited to 'src/protocols/GlobalShortcuts.cpp')
-rw-r--r--src/protocols/GlobalShortcuts.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/protocols/GlobalShortcuts.cpp b/src/protocols/GlobalShortcuts.cpp
index ca67f063..6fac2d7f 100644
--- a/src/protocols/GlobalShortcuts.cpp
+++ b/src/protocols/GlobalShortcuts.cpp
@@ -1,7 +1,7 @@
#include "GlobalShortcuts.hpp"
CShortcutClient::CShortcutClient(SP<CHyprlandGlobalShortcutsManagerV1> resource_) : resource(resource_) {
- if (!good())
+ if UNLIKELY (!good())
return;
resource->setOnDestroy([this](CHyprlandGlobalShortcutsManagerV1* pMgr) { PROTO::globalShortcuts->destroyResource(this); });
@@ -9,7 +9,7 @@ CShortcutClient::CShortcutClient(SP<CHyprlandGlobalShortcutsManagerV1> resource_
resource->setRegisterShortcut([this](CHyprlandGlobalShortcutsManagerV1* pMgr, uint32_t shortcut, const char* id, const char* app_id, const char* description,
const char* trigger_description) {
- if (PROTO::globalShortcuts->isTaken(id, app_id)) {
+ if UNLIKELY (PROTO::globalShortcuts->isTaken(id, app_id)) {
resource->error(HYPRLAND_GLOBAL_SHORTCUTS_MANAGER_V1_ERROR_ALREADY_TAKEN, "Combination is taken");
return;
}
@@ -20,7 +20,7 @@ CShortcutClient::CShortcutClient(SP<CHyprlandGlobalShortcutsManagerV1> resource_
PSHORTCUT->appid = app_id;
PSHORTCUT->shortcut = shortcut;
- if (!PSHORTCUT->resource->resource()) {
+ if UNLIKELY (!PSHORTCUT->resource->resource()) {
PSHORTCUT->resource->noMemory();
shortcuts.pop_back();
return;
@@ -41,7 +41,7 @@ CGlobalShortcutsProtocol::CGlobalShortcutsProtocol(const wl_interface* iface, co
void CGlobalShortcutsProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
const auto RESROUCE = m_vClients.emplace_back(makeShared<CShortcutClient>(makeShared<CHyprlandGlobalShortcutsManagerV1>(client, ver, id)));
- if (!RESROUCE->good()) {
+ if UNLIKELY (!RESROUCE->good()) {
wl_client_post_no_memory(client);
m_vClients.pop_back();
return;