diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-04-29 14:12:50 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-04-29 14:12:50 -0300 |
commit | 88bf2f83c035e612db103d7138a8312c455e4c88 (patch) | |
tree | e11d49feacbe6c78d5f07d621878852590813915 /ltable.c | |
parent | 8fff05f6d00802fa47614d681f1c7a17694856e8 (diff) | |
download | lua-88bf2f83c035e612db103d7138a8312c455e4c88.tar.gz lua-88bf2f83c035e612db103d7138a8312c455e4c88.tar.bz2 lua-88bf2f83c035e612db103d7138a8312c455e4c88.zip |
new function 'tointeger' + 'luaV_arith' replaced by 'luaT_trybinTM'
Diffstat (limited to 'ltable.c')
-rw-r--r-- | ltable.c | 17 |
1 files changed, 3 insertions, 14 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltable.c,v 2.73 2013/04/15 15:44:46 roberto Exp roberto $ | 2 | ** $Id: ltable.c,v 2.74 2013/04/26 15:39:25 roberto Exp roberto $ |
3 | ** Lua tables (hash) | 3 | ** Lua tables (hash) |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -123,17 +123,6 @@ static Node *mainposition (const Table *t, const TValue *key) { | |||
123 | } | 123 | } |
124 | 124 | ||
125 | 125 | ||
126 | static int numisint (lua_Number n, lua_Integer *p) { | ||
127 | lua_Integer k; | ||
128 | lua_number2integer(k, n); | ||
129 | if (luai_numeq(cast_num(k), n)) { /* 'k' is int? */ | ||
130 | *p = k; | ||
131 | return 1; | ||
132 | } | ||
133 | return 0; | ||
134 | } | ||
135 | |||
136 | |||
137 | /* | 126 | /* |
138 | ** returns the index for `key' if `key' is an appropriate key to live in | 127 | ** returns the index for `key' if `key' is an appropriate key to live in |
139 | ** the array part of the table, -1 otherwise. | 128 | ** the array part of the table, -1 otherwise. |
@@ -423,7 +412,7 @@ TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) { | |||
423 | lua_Integer k; | 412 | lua_Integer k; |
424 | if (luai_numisnan(L, n)) | 413 | if (luai_numisnan(L, n)) |
425 | luaG_runerror(L, "table index is NaN"); | 414 | luaG_runerror(L, "table index is NaN"); |
426 | if (numisint(n, &k)) { /* index is int? */ | 415 | if (luaV_numtointeger(n, &k)) { /* index is int? */ |
427 | setivalue(&aux, k); | 416 | setivalue(&aux, k); |
428 | key = &aux; /* insert it as an integer */ | 417 | key = &aux; /* insert it as an integer */ |
429 | } | 418 | } |
@@ -505,7 +494,7 @@ const TValue *luaH_get (Table *t, const TValue *key) { | |||
505 | case LUA_TNIL: return luaO_nilobject; | 494 | case LUA_TNIL: return luaO_nilobject; |
506 | case LUA_TNUMFLT: { | 495 | case LUA_TNUMFLT: { |
507 | lua_Integer k; | 496 | lua_Integer k; |
508 | if (numisint(fltvalue(key), &k)) /* index is int? */ | 497 | if (luaV_numtointeger(fltvalue(key), &k)) /* index is int? */ |
509 | return luaH_getint(t, k); /* use specialized version */ | 498 | return luaH_getint(t, k); /* use specialized version */ |
510 | /* else go through */ | 499 | /* else go through */ |
511 | } | 500 | } |