[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Ruby?
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Tue, 26 Sep 2000 08:18:40 -0300 (EST)
>Please could you explain why local variables are so much faster than
>globals.
Globals need a table look-up. Locals are indices into the stack.
Here is the relevant section of lvm.c:
case OP_GETLOCAL: {
*top++ = *(base+GETARG_U(i));
break;
}
case OP_GETGLOBAL: {
L->top = top;
*top = *luaV_getglobal(L, kstr[GETARG_U(i)]);
top++;
break;
}
--lhf