This optimization might land in the next Lua release. More specifically, the "Reflected Arrays" version (Figure 6).
https://github.com/lua/lua/blob/f71156744851701b5d5fabdda506...