[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: luaL_checkudata for invalid index?
- From: Roberto Ierusalimschy <roberto@...>
- Date: Fri, 22 Feb 2013 14:00:48 -0300
> Does this mean it's more efficient to reference stack positions by positive
> numbers (first if clause) or by negative numbers (couple less lines of
> code)? I have small functions where I (as a programmer) don't care one way
> or the other, but if there's a slight gain I could do it that way (some of
> these small functions are executed many times).
You can measure to see if there is any difference. But almost always
one of the ways is more "natural" than the other (e.g., easier to see
that it is correct).
> If the stack index is negative but greater than the stack size, that would
> be bad, right?
Yes.
-- Roberto