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/DataDeviceWlr.cpp | |
| parent | 2bad73354a5dbb9be8ba9a39b6238017a216a25b (diff) | |
core: add LIKELY and UNLIKELY macros
helps the compiler optimize
Diffstat (limited to 'src/protocols/DataDeviceWlr.cpp')
| -rw-r--r-- | src/protocols/DataDeviceWlr.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/protocols/DataDeviceWlr.cpp b/src/protocols/DataDeviceWlr.cpp index d8103d11..71ee1c4a 100644 --- a/src/protocols/DataDeviceWlr.cpp +++ b/src/protocols/DataDeviceWlr.cpp @@ -4,7 +4,7 @@ #include "core/Seat.hpp" CWLRDataOffer::CWLRDataOffer(SP<CZwlrDataControlOfferV1> resource_, SP<IDataSource> source_) : source(source_), resource(resource_) { - if (!good()) + if UNLIKELY (!good()) return; resource->setDestroy([this](CZwlrDataControlOfferV1* r) { PROTO::dataWlr->destroyResource(this); }); @@ -34,7 +34,7 @@ bool CWLRDataOffer::good() { } void CWLRDataOffer::sendData() { - if (!source) + if UNLIKELY (!source) return; for (auto const& m : source->mimes()) { @@ -43,7 +43,7 @@ void CWLRDataOffer::sendData() { } CWLRDataSource::CWLRDataSource(SP<CZwlrDataControlSourceV1> resource_, SP<CWLRDataDevice> device_) : device(device_), resource(resource_) { - if (!good()) + if UNLIKELY (!good()) return; resource->setData(this); @@ -104,7 +104,7 @@ void CWLRDataSource::error(uint32_t code, const std::string& msg) { } CWLRDataDevice::CWLRDataDevice(SP<CZwlrDataControlDeviceV1> resource_) : resource(resource_) { - if (!good()) + if UNLIKELY (!good()) return; pClient = resource->client(); @@ -173,7 +173,7 @@ void CWLRDataDevice::sendPrimarySelection(SP<CWLRDataOffer> selection) { } CWLRDataControlManagerResource::CWLRDataControlManagerResource(SP<CZwlrDataControlManagerV1> resource_) : resource(resource_) { - if (!good()) + if UNLIKELY (!good()) return; resource->setDestroy([this](CZwlrDataControlManagerV1* r) { PROTO::dataWlr->destroyResource(this); }); @@ -182,7 +182,7 @@ CWLRDataControlManagerResource::CWLRDataControlManagerResource(SP<CZwlrDataContr resource->setGetDataDevice([this](CZwlrDataControlManagerV1* r, uint32_t id, wl_resource* seat) { const auto RESOURCE = PROTO::dataWlr->m_vDevices.emplace_back(makeShared<CWLRDataDevice>(makeShared<CZwlrDataControlDeviceV1>(r->client(), r->version(), id))); - if (!RESOURCE->good()) { + if UNLIKELY (!RESOURCE->good()) { r->noMemory(); PROTO::dataWlr->m_vDevices.pop_back(); return; @@ -208,7 +208,7 @@ CWLRDataControlManagerResource::CWLRDataControlManagerResource(SP<CZwlrDataContr const auto RESOURCE = PROTO::dataWlr->m_vSources.emplace_back(makeShared<CWLRDataSource>(makeShared<CZwlrDataControlSourceV1>(r->client(), r->version(), id), device.lock())); - if (!RESOURCE->good()) { + if UNLIKELY (!RESOURCE->good()) { r->noMemory(); PROTO::dataWlr->m_vSources.pop_back(); return; @@ -236,7 +236,7 @@ CDataDeviceWLRProtocol::CDataDeviceWLRProtocol(const wl_interface* iface, const void CDataDeviceWLRProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) { const auto RESOURCE = m_vManagers.emplace_back(makeShared<CWLRDataControlManagerResource>(makeShared<CZwlrDataControlManagerV1>(client, ver, id))); - if (!RESOURCE->good()) { + if UNLIKELY (!RESOURCE->good()) { wl_client_post_no_memory(client); m_vManagers.pop_back(); return; |
