[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Suggestion: lua_popinteger and others
- From: Rebel Neurofog <rebelneurofog@...>
- Date: Wed, 25 Apr 2012 08:50:07 +0400
On Tue, Apr 24, 2012 at 11:00 AM, Rena <hyperhacker@gmail.com> wrote:
> Right now if you want to retrieve a field using the C API, it takes
> three lines per field:
> lua_getfield(L, index, "field name");
> lua_Integer val = lua_tointeger(L, -1);
> lua_pop(L, 1);
static inline lua_Integer get_integer (lua_State *L, int idx, const char *field)
{
lua_getfield(L, idx, field);
lua_Integer val = lua_tointeger(L, -1);
lua_pop(L, 1);
return val;
}
In modern compilers inlining avoids unnecessary data copying so this
is at least optimal.
Although inlining isn't ASNI C.