thijse / Arduino-CmdMessenger

CmdMessenger Communication library for Arduino & .NET
Other
208 stars 87 forks source link

remove callback list and attach(id, callback) #17

Closed Palatis closed 7 years ago

Palatis commented 7 years ago

taking too much memory space... just do it in the default handler with a big switch-case would be more memory efficient (saved a bit code space, too)...

Palatis commented 7 years ago

I understand this is an "programming interface breaking" commit, but 50 function pointers is taking up 100 bytes of memory... i rather use it for the cmd cache instead of bunch of callbacks...

valkuc commented 7 years ago

If you don't need dedicated callbacks - don't use them. Just set MAXCALLBACKS to 0 and use default callback handler with switch-case.

Palatis commented 7 years ago

waists one byte of memory to store callbacks[0]... XD

thijse commented 7 years ago

I think for most people the convenience of having the callback mechanism outweighs the loss of available memory, especially if they adjust MAXCALLBACKS to required number. Additionally, as @valkuc says, you can effectively disable the functionality and add your own switch statement,

Palatis commented 7 years ago

yeah working on a version that's easier for the user to choose from what to do, which don't break backward compatibility.