mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 03:53:09 +00:00
Update lua 5.4.3 rc1
This commit is contained in:
@@ -309,7 +309,7 @@ static unsigned int findindex (lua_State *L, Table *t, TValue *key,
|
||||
return i; /* yes; that's the index */
|
||||
else {
|
||||
const TValue *n = getgeneric(t, key, 1);
|
||||
if (unlikely(isabstkey(n)))
|
||||
if (l_unlikely(isabstkey(n)))
|
||||
luaG_runerror(L, "invalid key to 'next'"); /* key not found */
|
||||
i = cast_int(nodefromval(n) - gnode(t, 0)); /* key index in hash table */
|
||||
/* hash elements are numbered after array ones */
|
||||
@@ -487,7 +487,7 @@ static void reinsert (lua_State *L, Table *ot, Table *t) {
|
||||
already present in the table */
|
||||
TValue k;
|
||||
getnodekey(L, &k, old);
|
||||
setobjt2t(L, luaH_set(L, t, &k), gval(old));
|
||||
luaH_set(L, t, &k, gval(old));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -543,7 +543,7 @@ void luaH_resize (lua_State *L, Table *t, unsigned int newasize,
|
||||
}
|
||||
/* allocate new array */
|
||||
newarray = luaM_reallocvector(L, t->array, oldasize, newasize, TValue);
|
||||
if (unlikely(newarray == NULL && newasize > 0)) { /* allocation failed? */
|
||||
if (l_unlikely(newarray == NULL && newasize > 0)) { /* allocation failed? */
|
||||
freehash(L, &newt); /* release new hash part */
|
||||
luaM_error(L); /* raise error (with array unchanged) */
|
||||
}
|
||||
@@ -634,10 +634,12 @@ static Node *getfreepos (Table *t) {
|
||||
** put new key in its main position; otherwise (colliding node is in its main
|
||||
** position), new key goes to an empty position.
|
||||
*/
|
||||
TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) {
|
||||
void luaH_newkey (lua_State *L, Table *t, const TValue *key, TValue *value) {
|
||||
Node *mp;
|
||||
TValue aux;
|
||||
if (unlikely(ttisnil(key)))
|
||||
if (l_unlikely(isshared(t)))
|
||||
luaG_runerror(L, "attempt to change a shared table");
|
||||
if (l_unlikely(ttisnil(key)))
|
||||
luaG_runerror(L, "table index is nil");
|
||||
else if (ttisfloat(key)) {
|
||||
lua_Number f = fltvalue(key);
|
||||
@@ -646,9 +648,11 @@ TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) {
|
||||
setivalue(&aux, k);
|
||||
key = &aux; /* insert it as an integer */
|
||||
}
|
||||
else if (unlikely(luai_numisnan(f)))
|
||||
else if (l_unlikely(luai_numisnan(f)))
|
||||
luaG_runerror(L, "table index is NaN");
|
||||
}
|
||||
if (ttisnil(value))
|
||||
return; /* do not insert nil values */
|
||||
mp = mainpositionTV(t, key);
|
||||
if (!isempty(gval(mp)) || isdummy(t)) { /* main position is taken? */
|
||||
Node *othern;
|
||||
@@ -656,7 +660,8 @@ TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) {
|
||||
if (f == NULL) { /* cannot find a free place? */
|
||||
rehash(L, t, key); /* grow table */
|
||||
/* whatever called 'newkey' takes care of TM cache */
|
||||
return luaH_set(L, t, key); /* insert key into grown table */
|
||||
luaH_set(L, t, key, value); /* insert key into grown table */
|
||||
return;
|
||||
}
|
||||
lua_assert(!isdummy(t));
|
||||
othern = mainposition(t, keytt(mp), &keyval(mp));
|
||||
@@ -684,7 +689,7 @@ TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) {
|
||||
setnodekey(L, mp, key);
|
||||
luaC_barrierback(L, obj2gco(t), key);
|
||||
lua_assert(isempty(gval(mp)));
|
||||
return gval(mp);
|
||||
setobj2t(L, gval(mp), value);
|
||||
}
|
||||
|
||||
|
||||
@@ -771,35 +776,46 @@ const TValue *luaH_get (Table *t, const TValue *key) {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Finish a raw "set table" operation, where 'slot' is where the value
|
||||
** should have been (the result of a previous "get table").
|
||||
** Beware: when using this function you probably need to check a GC
|
||||
** barrier and invalidate the TM cache.
|
||||
*/
|
||||
void luaH_finishset (lua_State *L, Table *t, const TValue *key,
|
||||
const TValue *slot, TValue *value) {
|
||||
if (isabstkey(slot))
|
||||
luaH_newkey(L, t, key, value);
|
||||
else {
|
||||
if (l_unlikely(isshared(t)))
|
||||
luaG_runerror(L, "attempt to change a shared table");
|
||||
setobj2t(L, cast(TValue *, slot), value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** beware: when using this function you probably need to check a GC
|
||||
** barrier and invalidate the TM cache.
|
||||
*/
|
||||
TValue *luaH_set (lua_State *L, Table *t, const TValue *key) {
|
||||
const TValue *p;
|
||||
if(isshared(t))
|
||||
luaG_runerror(L, "attempt to change a shared table");
|
||||
p = luaH_get(t, key);
|
||||
if (!isabstkey(p))
|
||||
return cast(TValue *, p);
|
||||
else return luaH_newkey(L, t, key);
|
||||
void luaH_set (lua_State *L, Table *t, const TValue *key, TValue *value) {
|
||||
const TValue *slot = luaH_get(t, key);
|
||||
luaH_finishset(L, t, key, slot, value);
|
||||
}
|
||||
|
||||
|
||||
void luaH_setint (lua_State *L, Table *t, lua_Integer key, TValue *value) {
|
||||
const TValue *p;
|
||||
TValue *cell;
|
||||
if(isshared(t))
|
||||
luaG_runerror(L, "attempt to change a shared table");
|
||||
p = luaH_getint(t, key);
|
||||
if (!isabstkey(p))
|
||||
cell = cast(TValue *, p);
|
||||
else {
|
||||
const TValue *p = luaH_getint(t, key);
|
||||
if (isabstkey(p)) {
|
||||
TValue k;
|
||||
setivalue(&k, key);
|
||||
cell = luaH_newkey(L, t, &k);
|
||||
luaH_newkey(L, t, &k, value);
|
||||
}
|
||||
else {
|
||||
if (l_unlikely(isshared(t)))
|
||||
luaG_runerror(L, "attempt to change a shared table");
|
||||
setobj2t(L, cast(TValue *, p), value);
|
||||
}
|
||||
setobj2t(L, cell, value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user