TerraME / terrame

TerraME is a programming environment for spatial dynamical modelling
www.terrame.org
GNU Lesser General Public License v3.0
35 stars 13 forks source link

Optimize reading CellularSpaces #1466

Open pedro-andrade-inpe opened 7 years ago

pedro-andrade-inpe commented 7 years ago

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.

https://www.lua.org/gems/sample.pdf

pedro-andrade-inpe commented 7 years ago

The implementation had some side effects that need to be fixed and so this issue was reopened.