Pazyryk
Deity
- Joined
- Jun 13, 2008
- Messages
- 3,584
GameInfoTypes is just a simple Lua table indexed by strings. So no speed problem there at all. GameInfo.Unit is actually of type userdata, meaning it is calling some kind of C++ somewhere. GameInfo.Unit() returns an iterator method. But like any C++ method passed to Lua, you can't see the contents of that method (from Lua), so that part is black box unless it happens to be in our DLL somewhere.
Edit: Accessing GameInfo.Units[1] is also very slow. That construct will get you a table. But it's not a table that was sitting around already in Lua. The GameInfo.Units part is sending you to C++ which (somehow) is generating a table for you. Again, I suspect it is doing this by querying the DB in real time rather than cached values. Actually I quite sure of that. Not only is it very slow, but you can do tests and see that GameInfo.Units[1] returns values that reflect post-init changes in DB.
Edit: Accessing GameInfo.Units[1] is also very slow. That construct will get you a table. But it's not a table that was sitting around already in Lua. The GameInfo.Units part is sending you to C++ which (somehow) is generating a table for you. Again, I suspect it is doing this by querying the DB in real time rather than cached values. Actually I quite sure of that. Not only is it very slow, but you can do tests and see that GameInfo.Units[1] returns values that reflect post-init changes in DB.