From 88bf2f83c035e612db103d7138a8312c455e4c88 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 29 Apr 2013 14:12:50 -0300 Subject: new function 'tointeger' + 'luaV_arith' replaced by 'luaT_trybinTM' --- ltable.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'ltable.c') diff --git a/ltable.c b/ltable.c index 00906642..2e95ce26 100644 --- a/ltable.c +++ b/ltable.c @@ -1,5 +1,5 @@ /* -** $Id: ltable.c,v 2.73 2013/04/15 15:44:46 roberto Exp roberto $ +** $Id: ltable.c,v 2.74 2013/04/26 15:39:25 roberto Exp roberto $ ** Lua tables (hash) ** See Copyright Notice in lua.h */ @@ -123,17 +123,6 @@ static Node *mainposition (const Table *t, const TValue *key) { } -static int numisint (lua_Number n, lua_Integer *p) { - lua_Integer k; - lua_number2integer(k, n); - if (luai_numeq(cast_num(k), n)) { /* 'k' is int? */ - *p = k; - return 1; - } - return 0; -} - - /* ** returns the index for `key' if `key' is an appropriate key to live in ** the array part of the table, -1 otherwise. @@ -423,7 +412,7 @@ TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) { lua_Integer k; if (luai_numisnan(L, n)) luaG_runerror(L, "table index is NaN"); - if (numisint(n, &k)) { /* index is int? */ + if (luaV_numtointeger(n, &k)) { /* index is int? */ setivalue(&aux, k); key = &aux; /* insert it as an integer */ } @@ -505,7 +494,7 @@ const TValue *luaH_get (Table *t, const TValue *key) { case LUA_TNIL: return luaO_nilobject; case LUA_TNUMFLT: { lua_Integer k; - if (numisint(fltvalue(key), &k)) /* index is int? */ + if (luaV_numtointeger(fltvalue(key), &k)) /* index is int? */ return luaH_getint(t, k); /* use specialized version */ /* else go through */ } -- cgit v1.2.3-55-g6feb