diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2004-05-10 14:50:51 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2004-05-10 14:50:51 -0300 |
commit | 7e41612eb28ff0fba282bd419781fcbc9bd94776 (patch) | |
tree | e63123d15589435c08c844b0d471b142c924818b /lvm.c | |
parent | b0f341ee52ee7d3d22261a68caf06eab5b0c8822 (diff) | |
download | lua-7e41612eb28ff0fba282bd419781fcbc9bd94776.tar.gz lua-7e41612eb28ff0fba282bd419781fcbc9bd94776.tar.bz2 lua-7e41612eb28ff0fba282bd419781fcbc9bd94776.zip |
code parameterized by LUA_FIRSTINDEX (first index of an array)
Diffstat (limited to 'lvm.c')
-rw-r--r-- | lvm.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 2.3 2004/03/26 14:02:41 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.4 2004/04/30 20:13:38 roberto Exp roberto $ |
3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -694,7 +694,7 @@ StkId luaV_execute (lua_State *L, int nexeccalls) { | |||
694 | case OP_SETLIST: | 694 | case OP_SETLIST: |
695 | case OP_SETLISTO: { | 695 | case OP_SETLISTO: { |
696 | int bc = GETARG_Bx(i); | 696 | int bc = GETARG_Bx(i); |
697 | int n; | 697 | int n, last; |
698 | Table *h; | 698 | Table *h; |
699 | runtime_check(L, ttistable(ra)); | 699 | runtime_check(L, ttistable(ra)); |
700 | h = hvalue(ra); | 700 | h = hvalue(ra); |
@@ -705,11 +705,12 @@ StkId luaV_execute (lua_State *L, int nexeccalls) { | |||
705 | L->top = L->ci->top; | 705 | L->top = L->ci->top; |
706 | } | 706 | } |
707 | bc &= ~(LFIELDS_PER_FLUSH-1); /* bc = bc - bc%FPF */ | 707 | bc &= ~(LFIELDS_PER_FLUSH-1); /* bc = bc - bc%FPF */ |
708 | if (bc+n > h->sizearray) /* needs more space? */ | 708 | last = bc + n + LUA_FIRSTINDEX - 1; |
709 | luaH_resize(L, h, bc+n, h->lsizenode); /* pre-alloc it at once */ | 709 | if (last > h->sizearray) /* needs more space? */ |
710 | luaH_resize(L, h, last, h->lsizenode); /* pre-alloc it at once */ | ||
710 | for (; n > 0; n--) { | 711 | for (; n > 0; n--) { |
711 | TValue *val = ra+n; | 712 | TValue *val = ra+n; |
712 | setobj2t(L, luaH_setnum(L, h, bc+n), val); | 713 | setobj2t(L, luaH_setnum(L, h, last--), val); |
713 | luaC_barrier(L, h, val); | 714 | luaC_barrier(L, h, val); |
714 | } | 715 | } |
715 | break; | 716 | break; |