aboutsummaryrefslogtreecommitdiff
path: root/ltable.c
diff options
context:
space:
mode:
Diffstat (limited to 'ltable.c')
-rw-r--r--ltable.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/ltable.c b/ltable.c
index 7113f0ff..56fe64fd 100644
--- a/ltable.c
+++ b/ltable.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltable.c,v 2.135 2018/02/26 14:16:05 roberto Exp roberto $ 2** $Id: ltable.c,v 2.136 2018/05/29 18:01:50 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*/
@@ -235,7 +235,7 @@ static unsigned int findindex (lua_State *L, Table *t, TValue *key) {
235 return i; /* yes; that's the index */ 235 return i; /* yes; that's the index */
236 else { 236 else {
237 const TValue *n = getgeneric(t, key); 237 const TValue *n = getgeneric(t, key);
238 if (n == luaH_emptyobject) 238 if (unlikely(n == luaH_emptyobject))
239 luaG_runerror(L, "invalid key to 'next'"); /* key not found */ 239 luaG_runerror(L, "invalid key to 'next'"); /* key not found */
240 i = cast_int(nodefromval(n) - gnode(t, 0)); /* key index in hash table */ 240 i = cast_int(nodefromval(n) - gnode(t, 0)); /* key index in hash table */
241 /* hash elements are numbered after array ones */ 241 /* hash elements are numbered after array ones */
@@ -467,7 +467,7 @@ void luaH_resize (lua_State *L, Table *t, unsigned int newasize,
467 } 467 }
468 /* allocate new array */ 468 /* allocate new array */
469 newarray = luaM_reallocvector(L, t->array, oldasize, newasize, TValue); 469 newarray = luaM_reallocvector(L, t->array, oldasize, newasize, TValue);
470 if (newarray == NULL && newasize > 0) { /* allocation failed? */ 470 if (unlikely(newarray == NULL && newasize > 0)) { /* allocation failed? */
471 freehash(L, &newt); /* release new hash part */ 471 freehash(L, &newt); /* release new hash part */
472 luaM_error(L); /* raise error (with array unchanged) */ 472 luaM_error(L); /* raise error (with array unchanged) */
473 } 473 }
@@ -560,7 +560,8 @@ static Node *getfreepos (Table *t) {
560TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) { 560TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) {
561 Node *mp; 561 Node *mp;
562 TValue aux; 562 TValue aux;
563 if (ttisnil(key)) luaG_runerror(L, "table index is nil"); 563 if (unlikely(ttisnil(key)))
564 luaG_runerror(L, "table index is nil");
564 else if (ttisfloat(key)) { 565 else if (ttisfloat(key)) {
565 lua_Number f = fltvalue(key); 566 lua_Number f = fltvalue(key);
566 lua_Integer k; 567 lua_Integer k;
@@ -568,7 +569,7 @@ TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) {
568 setivalue(&aux, k); 569 setivalue(&aux, k);
569 key = &aux; /* insert it as an integer */ 570 key = &aux; /* insert it as an integer */
570 } 571 }
571 else if (luai_numisnan(f)) 572 else if (unlikely(luai_numisnan(f)))
572 luaG_runerror(L, "table index is NaN"); 573 luaG_runerror(L, "table index is NaN");
573 } 574 }
574 mp = mainpositionTV(t, key); 575 mp = mainpositionTV(t, key);