lua

A copy of the Lua development repository
Log | Files | Refs | README

commit 15a3738b4994cc8bbe23d73d640743338ae22b02
parent a83ed55f1e3e20f73d01489c18889bb8554593ce
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Thu,  7 Mar 2013 15:16:59 -0300

no need to handle 0 as a special case in 'table.remove'

Diffstat:
Mltablib.c | 4+---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/ltablib.c b/ltablib.c @@ -1,5 +1,5 @@ /* -** $Id: ltablib.c,v 1.63 2011/11/28 17:26:30 roberto Exp roberto $ +** $Id: ltablib.c,v 1.64 2013/02/06 18:29:03 roberto Exp roberto $ ** Library for Table Manipulation ** See Copyright Notice in lua.h */ @@ -70,8 +70,6 @@ static int tremove (lua_State *L) { int pos = luaL_optint(L, 2, size); if (pos != size) /* validate 'pos' if given */ luaL_argcheck(L, 1 <= pos && pos <= size + 1, 1, "position out of bounds"); - else if (size == 0) /* empty table? */ - return 0; /* return nothing (nil) */ lua_rawgeti(L, 1, pos); /* result = t[pos] */ for ( ; pos < size; pos++) { lua_rawgeti(L, 1, pos+1);