When reading a CellularSpace from a file or a database, we already know how many attributes are going to be read before creating Cells. It is possible to optimize this to avoid rehashing when we insert the first, second, fourth attribute, and so on:
If you are programming in C, you can avoid those rehashings with the Lua
API function lua_createtable. It receives two arguments after the omnipresent
lua_State: the initial size of the array part and the initial size of the hash part
of the new table. By giving appropriate sizes to the new table, it is easy to avoid
those initial rehashes.
When reading a CellularSpace from a file or a database, we already know how many attributes are going to be read before creating Cells. It is possible to optimize this to avoid rehashing when we insert the first, second, fourth attribute, and so on:
https://www.lua.org/gems/sample.pdf