lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Am 17.12.2012 07:07, schrieb steve donovan:
On Sun, Dec 16, 2012 at 6:49 PM, Philipp Janda <siffiejoe@gmx.net> wrote:
Am I missing something here?

function extend( t, ... )
   for i = 1, select( '#', ... ) do
     local a = select( i, ... )

Actually, you've got it there - these are not particularly fast
functions, but the number of tables is small, so this is efficient
enough.

Any reasons why these are not particularly fast functions? The select function calls use only four Lua API calls (lua_gettop, lua_type, lua_tostring, and lua_pushinteger in the first case and lua_gettop, lua_type, luaL_checkint, and luaL_argcheck in the second case). And all of them except lua_pushinteger just access some struct field, evaluate some condition, and/or cast a double to an integer.
Or did you mean that function calls in general are slow?


steve d.


Philipp