Skip to content
Snippets Groups Projects
Commit 2ee5d533 authored by Christian Werner's avatar Christian Werner
Browse files

update: optimize for size

parent a997bc00
No related branches found
No related tags found
No related merge requests found
#pragma once
#include "ButtonEvent.h"
ButtonEvent::ButtonEvent(press_t type, button_t source) {
typeId = type;
sourceId = source;
}
ButtonEvent::press_t ButtonEvent::getType() const {
return typeId;
}
ButtonEvent::button_t ButtonEvent::getSource() const {
return sourceId;
}
\ No newline at end of file
......@@ -5,10 +5,16 @@ class ButtonEvent {
enum press_t{shortPress, longPress, veryLongPress};
enum button_t{button1, button2};
ButtonEvent(press_t type = shortPress, button_t source = button1);
ButtonEvent(press_t type = shortPress, button_t source = button1) // inline constructor an use initilizer list (-8 bytes in .text)
: typeId{type}, sourceId{source}
{}
press_t getType() const;
button_t getSource() const;
press_t getType() const { // inline (con change)
return typeId;
}
button_t getSource() const { // inline (no change)
return sourceId;
}
private:
press_t typeId;
......
......@@ -7,10 +7,6 @@
#include "ButtonEventDispatcher.h"
ButtonEventDispatcher::ButtonEventDispatcher()
:callbackFuncPtr{}
{}
void ButtonEventDispatcher::Dispatch(const ButtonEvent& e) const {
for (size_t i = 0 ; i < capacity; i++) {
if (callbackFuncPtr[i]) callbackFuncPtr[i](e);
......
......@@ -11,7 +11,10 @@ private:
public:
typedef void (*callbackPtr_t)(const ButtonEvent& e);
ButtonEventDispatcher();
ButtonEventDispatcher() // inline ctor (-8 bytes in .text)
:callbackFuncPtr{}
{}
void Dispatch(const ButtonEvent& e) const;
void RegisterButtonHandler(callbackPtr_t cb);
void UnregisterButtonHandler(callbackPtr_t cb);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment