Because Mouse is always instantiated, the constructor always runs, and thus, the node is always registered whenever the Mouse object is referenced, even if done so in code that gets optimized out. To combat this, and allow the compiler to optimize out Mouse fully, do the append in Mouse.begin. This way, if the Mouse global is referenced by code that gets optimized out, the constructor will be optimized out, allowing the full object to get dropped. As we call Mouse.begin during setup, there is no risk doing a late append, either.
This addresses the most important part of keyboardio/Kaleidoscope#257.
Because
Mouse
is always instantiated, the constructor always runs, and thus, the node is always registered whenever theMouse
object is referenced, even if done so in code that gets optimized out. To combat this, and allow the compiler to optimize outMouse
fully, do the append inMouse.begin
. This way, if theMouse
global is referenced by code that gets optimized out, the constructor will be optimized out, allowing the full object to get dropped. As we callMouse.begin
duringsetup
, there is no risk doing a late append, either.This addresses the most important part of keyboardio/Kaleidoscope#257.