diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-10-21 11:47:42 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-10-21 11:47:42 -0200 |
| commit | 053e87314596e48588a929791012def7818ec989 (patch) | |
| tree | e5ce2b8bdf03da3dbdac087bf62824b49e7d40f0 /ltablib.c | |
| parent | 9f4211310fcea9ebf08f4884f8665520c1b8d85f (diff) | |
| download | lua-053e87314596e48588a929791012def7818ec989.tar.gz lua-053e87314596e48588a929791012def7818ec989.tar.bz2 lua-053e87314596e48588a929791012def7818ec989.zip | |
new macro luaL_opt to avoid evaluating defaults when no needed
Diffstat (limited to 'ltablib.c')
| -rw-r--r-- | ltablib.c | 9 |
1 files changed, 4 insertions, 5 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltablib.c,v 1.35 2005/08/26 17:36:32 roberto Exp roberto $ | 2 | ** $Id: ltablib.c,v 1.36 2005/09/20 17:56:47 roberto Exp roberto $ |
| 3 | ** Library for Table Manipulation | 3 | ** Library for Table Manipulation |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -127,12 +127,11 @@ static int tremove (lua_State *L) { | |||
| 127 | static int tconcat (lua_State *L) { | 127 | static int tconcat (lua_State *L) { |
| 128 | luaL_Buffer b; | 128 | luaL_Buffer b; |
| 129 | size_t lsep; | 129 | size_t lsep; |
| 130 | int i, last; | ||
| 130 | const char *sep = luaL_optlstring(L, 2, "", &lsep); | 131 | const char *sep = luaL_optlstring(L, 2, "", &lsep); |
| 131 | int i = luaL_optint(L, 3, 1); | ||
| 132 | int last = luaL_optint(L, 4, -2); | ||
| 133 | luaL_checktype(L, 1, LUA_TTABLE); | 132 | luaL_checktype(L, 1, LUA_TTABLE); |
| 134 | if (last == -2) | 133 | i = luaL_optint(L, 3, 1); |
| 135 | last = luaL_getn(L, 1); | 134 | last = luaL_opt(L, luaL_checkint, 4, luaL_getn(L, 1)); |
| 136 | luaL_buffinit(L, &b); | 135 | luaL_buffinit(L, &b); |
| 137 | for (; i <= last; i++) { | 136 | for (; i <= last; i++) { |
| 138 | lua_rawgeti(L, 1, i); | 137 | lua_rawgeti(L, 1, i); |
