Back to smallsm

784 bytes down to 4

v0.1 reserved a slot for every hook. v0.2 reserves one only when you declare it.

Version Change Size Fixed cycle Random events
v0.1 Function pointer table 784 B 2.17 ns 4.87 ns
v0.1 Unrolled index comparison 784 B 1.18 ns 4.19 ns
v0.2 Hooks declared in the table 4 B 0.18 ns 3.88 ns

v0.1 reserved a callback slot for every possible hook on every transition and state. The benchmark machine declares no hooks, and it still included all of those slots.

In v0.2, a transition or state only gets a slot if the table declares guarded_t, built_t, entry_hook_t or exit_hook_t. Each declared slot adds 48 bytes on 64-bit and one check on the transitions that use it.