What can I do to increase the performance of a Lua program?

后端 未结 5 611
灰色年华
灰色年华 2020-12-07 09:03

I asked a question about Lua perfromance, and on of the responses asked:

Have you studied general tips for keeping Lua performance high? i.e. know tab

5条回答
  •  半阙折子戏
    2020-12-07 09:13

    It must be also pointed that using array fields from tables is much faster than using tables with any kind of key. It happens (almost) all Lua implementations (including LuaJ) store a called "array part" inside tables, which is accessed by the table array fields, and doesn't store the field key, nor lookup for it ;).

    You can even also imitate static aspects of other languages like struct, C++/Java class, etc.. Locals and arrays are enough.

提交回复
热议问题