misc: a few compiler level performance optimisations (#6559)
* window: use const references instead of copies use const references instead of wasteful copies and make the = operator check for self assignment and return early. also use const in all the other operators. * listener: pass std::function as const reference instead of copies pass the std::functions as const references. * config: dont unnecessarily convert to c_str getHyprlangConfigValuePtr wants an std::string and we already have an std::string, dont convert it to a c_str only for it to be converted back to an std::string. * buffer: pass attributes as const reference pass attributes as const reference instead of copies.
This commit is contained in:
parent
a9c7a0830f
commit
28ce0e0f80
6 changed files with 24 additions and 20 deletions
|
|
@ -18,7 +18,7 @@ void handleWrapped(wl_listener* listener, void* data) {
|
|||
g_pWatchdog->endWatching();
|
||||
}
|
||||
|
||||
CHyprWLListener::CHyprWLListener(wl_signal* pSignal, std::function<void(void*, void*)> callback, void* pOwner) {
|
||||
CHyprWLListener::CHyprWLListener(wl_signal* pSignal, std::function<void(void*, void*)> const& callback, void* pOwner) {
|
||||
initCallback(pSignal, callback, pOwner);
|
||||
}
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ bool CHyprWLListener::isConnected() {
|
|||
return !wl_list_empty(&m_swWrapper.m_sListener.link);
|
||||
}
|
||||
|
||||
void CHyprWLListener::initCallback(wl_signal* pSignal, std::function<void(void*, void*)> callback, void* pOwner, std::string author) {
|
||||
void CHyprWLListener::initCallback(wl_signal* pSignal, std::function<void(void*, void*)> const& callback, void* pOwner, std::string author) {
|
||||
if (isConnected()) {
|
||||
Debug::log(ERR, "Tried to connect a listener twice?!");
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
class CHyprWLListener {
|
||||
public:
|
||||
CHyprWLListener(wl_signal*, std::function<void(void*, void*)>, void* owner);
|
||||
CHyprWLListener(wl_signal*, std::function<void(void*, void*)> const&, void* owner);
|
||||
CHyprWLListener();
|
||||
~CHyprWLListener();
|
||||
|
||||
|
|
@ -15,7 +15,7 @@ class CHyprWLListener {
|
|||
CHyprWLListener& operator=(const CHyprWLListener&) = delete;
|
||||
CHyprWLListener& operator=(CHyprWLListener&&) = delete;
|
||||
|
||||
void initCallback(wl_signal*, std::function<void(void*, void*)>, void* owner, std::string author = "");
|
||||
void initCallback(wl_signal*, std::function<void(void*, void*)> const&, void* owner, std::string author = "");
|
||||
|
||||
void removeCallback();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue