Optimization

Use Locals

Local variables are stored in registers of the lua virtual machine and access to them is faster then globals. Also functions can be stored in locals if they are called in a loop.

Table Rehash

Use a constructor to avoid rehasing for smaller tables.