diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-12-04 11:08:42 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2020-12-04 11:08:42 -0300 |
commit | 23051e830a8b212f831443eb888e93e30fa8bb19 (patch) | |
tree | 782f56415ad3a8799c4dea8d6d329f1550d3d7c3 /lvm.c | |
parent | f15589f3b0da477e5dda8863cbf4c0b36469e36d (diff) | |
download | lua-23051e830a8b212f831443eb888e93e30fa8bb19.tar.gz lua-23051e830a8b212f831443eb888e93e30fa8bb19.tar.bz2 lua-23051e830a8b212f831443eb888e93e30fa8bb19.zip |
Changes in the API of 'luaH_set' and related functions
Functions to set values in a table (luaH_set, luaH_newkey, etc.) receive
the new value, instead of returning a slot where to put the value.
Diffstat (limited to 'lvm.c')
-rw-r--r-- | lvm.c | 5 |
1 files changed, 1 insertions, 4 deletions
@@ -337,10 +337,7 @@ void luaV_finishset (lua_State *L, const TValue *t, TValue *key, | |||
337 | lua_assert(isempty(slot)); /* slot must be empty */ | 337 | lua_assert(isempty(slot)); /* slot must be empty */ |
338 | tm = fasttm(L, h->metatable, TM_NEWINDEX); /* get metamethod */ | 338 | tm = fasttm(L, h->metatable, TM_NEWINDEX); /* get metamethod */ |
339 | if (tm == NULL) { /* no metamethod? */ | 339 | if (tm == NULL) { /* no metamethod? */ |
340 | if (isabstkey(slot)) /* no previous entry? */ | 340 | luaH_finishset(L, h, key, slot, val); /* set new value */ |
341 | slot = luaH_newkey(L, h, key); /* create one */ | ||
342 | /* no metamethod and (now) there is an entry with given key */ | ||
343 | setobj2t(L, cast(TValue *, slot), val); /* set its new value */ | ||
344 | invalidateTMcache(h); | 341 | invalidateTMcache(h); |
345 | luaC_barrierback(L, obj2gco(h), val); | 342 | luaC_barrierback(L, obj2gco(h), val); |
346 | return; | 343 | return; |