core: add LIKELY and UNLIKELY macros
helps the compiler optimize
This commit is contained in:
parent
2bad73354a
commit
b7a3c45269
58 changed files with 395 additions and 396 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue