diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2004-03-26 11:02:41 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2004-03-26 11:02:41 -0300 |
commit | 4c5d7b2dddeb853b61489d02b738572eb29cb323 (patch) | |
tree | 98fd0c7ad24d788bb60c8aee568fad856f630b89 /lvm.c | |
parent | d7cb62286642b0f5c16057373ff129109e1a3e8a (diff) | |
download | lua-4c5d7b2dddeb853b61489d02b738572eb29cb323.tar.gz lua-4c5d7b2dddeb853b61489d02b738572eb29cb323.tar.bz2 lua-4c5d7b2dddeb853b61489d02b738572eb29cb323.zip |
small optimization for {f()}
Diffstat (limited to 'lvm.c')
-rw-r--r-- | lvm.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 2.1 2003/12/10 12:13:36 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.2 2004/03/16 12:31:40 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 | */ |
@@ -701,12 +701,11 @@ StkId luaV_execute (lua_State *L, int nexeccalls) { | |||
701 | } | 701 | } |
702 | case OP_SETLIST: | 702 | case OP_SETLIST: |
703 | case OP_SETLISTO: { | 703 | case OP_SETLISTO: { |
704 | int bc; | 704 | int bc = GETARG_Bx(i); |
705 | int n; | 705 | int n; |
706 | Table *h; | 706 | Table *h; |
707 | runtime_check(L, ttistable(ra)); | 707 | runtime_check(L, ttistable(ra)); |
708 | h = hvalue(ra); | 708 | h = hvalue(ra); |
709 | bc = GETARG_Bx(i); | ||
710 | if (GET_OPCODE(i) == OP_SETLIST) | 709 | if (GET_OPCODE(i) == OP_SETLIST) |
711 | n = (bc&(LFIELDS_PER_FLUSH-1)) + 1; | 710 | n = (bc&(LFIELDS_PER_FLUSH-1)) + 1; |
712 | else { | 711 | else { |
@@ -714,6 +713,8 @@ StkId luaV_execute (lua_State *L, int nexeccalls) { | |||
714 | L->top = L->ci->top; | 713 | L->top = L->ci->top; |
715 | } | 714 | } |
716 | bc &= ~(LFIELDS_PER_FLUSH-1); /* bc = bc - bc%FPF */ | 715 | bc &= ~(LFIELDS_PER_FLUSH-1); /* bc = bc - bc%FPF */ |
716 | if (bc+n > h->sizearray) /* needs more space? */ | ||
717 | luaH_resize(L, h, bc+n, h->lsizenode); /* pre-alloc it at once */ | ||
717 | for (; n > 0; n--) { | 718 | for (; n > 0; n--) { |
718 | TValue *val = ra+n; | 719 | TValue *val = ra+n; |
719 | setobj2t(L, luaH_setnum(L, h, bc+n), val); | 720 | setobj2t(L, luaH_setnum(L, h, bc+n), val); |