Profiling run showed that now action_by_number() is a major performance bottleneck (took over 10% of the run time).
In addition to the function call overhead, it does work that's redundant for most callers: it's called A LOT inside action_iterate(). The action_iterate() iterates over valid actions only, so no point to do all that checking of action validity in those action_by_number() calls.
There's several ways we could rework this. One is to inline the function, trusting that the compiler then detects what's redundant in each call, and optimizes. In a quick test with inlined action_by_number(), there was a huge improvement in the total run time of an autogame.
3.0.3 release is coming sooner than earlier expected -> don't want to take unnecessary risks of regressions (with the limited time that this would be tested in branch).
Profiling run showed that now action_by_number() is a major performance bottleneck (took over 10% of the run time).
In addition to the function call overhead, it does work that's redundant for most callers: it's called A LOT inside action_iterate(). The action_iterate() iterates over valid actions only, so no point to do all that checking of action validity in those action_by_number() calls.
There's several ways we could rework this. One is to inline the function, trusting that the compiler then detects what's redundant in each call, and optimizes. In a quick test with inlined action_by_number(), there was a huge improvement in the total run time of an autogame.