I have a strong urge to replace the framework-provided loop()
function with my own like so:
__attribute__((always_inline)) inline void fastLoop()
{
}
void setup()
{
// Performing setup here...
Serial.begin(115200);
// Now looping
for(;;)
fastLoop();
}
This way, my loop is inlined and I'm saving quite a few cycles - avoiding not only Arduino housekeeping costs, but also the function call cost which even for a void function has to be at least 6 cycles on AVR (>=2 for RCALL and 4 for RET).
This is the framework code for calling loop()
from main()
:
for (;;) {
loop();
if (serialEventRun) serialEventRun();
}
My question is: what does this serialEvent
stuff do? What features of the framework will stop working properly with my own loop?
Assuming my loop has observable side effects as required by the C++ standard, of course (otherwise it can be optimized out).