TheOpenSpaceProgram / new-ospgl

A space exploration game in OpenGL. Devblog: https://tatjam.github.io/index.html
MIT License
43 stars 6 forks source link

Performance of overriding ipairs() #50

Closed tatjam closed 1 year ago

tatjam commented 1 year ago

We must measure the performance hit of this code here: https://github.com/TheOpenSpaceProgram/new-ospgl/blob/833093b670545ef89d1a71166ac22577feda6e36/src/lua/LuaCore.cpp#L184

If it's not satisfying (it probably is, but LuaJIT can have some surprises), then std::vectors must be accessed using slightly non lua style syntax. Instead of:

for index, value in ipairs(vector)

you would use

for index, value in vector:pairs()

This is still the case for std::unordered_map and similar as these cannot be fixed this way and would require changes to the sol library.

tatjam commented 1 year ago

This doesn't matter anymore as the LuaJIT Lua 5.2 compatibility mode was enabled.