summaryrefslogtreecommitdiff
path: root/lapi.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2021-09-15 11:18:41 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2021-09-15 11:18:41 -0300
commit2ff34717227b8046b0fdcb96206f11f5e888664e (patch)
tree112f054406eaa82363716882b4300d4ff98ab2ef /lapi.c
parent9db4bfed6bb9d5828c99c0f24749eedf54d70cc2 (diff)
downloadlua-github-2ff34717227b8046b0fdcb96206f11f5e888664e.tar.gz
Using 'inline' in some functions
According to ISO C, "making a function an inline function suggests that calls to the function be as fast as possible." (Not available in C89.)
Diffstat (limited to 'lapi.c')
-rw-r--r--lapi.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/lapi.c b/lapi.c
index 34678917..071a06f3 100644
--- a/lapi.c
+++ b/lapi.c
@@ -86,10 +86,12 @@ static TValue *index2value (lua_State *L, int idx) {
}
}
+
+
/*
** Convert a valid actual index (not a pseudo-index) to its address.
*/
-static StkId index2stack (lua_State *L, int idx) {
+l_sinline StkId index2stack (lua_State *L, int idx) {
CallInfo *ci = L->ci;
if (idx > 0) {
StkId o = ci->func + idx;
@@ -226,7 +228,7 @@ LUA_API void lua_closeslot (lua_State *L, int idx) {
** Note that we move(copy) only the value inside the stack.
** (We do not move additional fields that may exist.)
*/
-static void reverse (lua_State *L, StkId from, StkId to) {
+l_sinline void reverse (lua_State *L, StkId from, StkId to) {
for (; from < to; from++, to--) {
TValue temp;
setobj(L, &temp, s2v(from));
@@ -446,7 +448,7 @@ LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) {
}
-static void *touserdata (const TValue *o) {
+l_sinline void *touserdata (const TValue *o) {
switch (ttype(o)) {
case LUA_TUSERDATA: return getudatamem(uvalue(o));
case LUA_TLIGHTUSERDATA: return pvalue(o);
@@ -638,7 +640,7 @@ LUA_API int lua_pushthread (lua_State *L) {
*/
-static int auxgetstr (lua_State *L, const TValue *t, const char *k) {
+l_sinline int auxgetstr (lua_State *L, const TValue *t, const char *k) {
const TValue *slot;
TString *str = luaS_new(L, k);
if (luaV_fastget(L, t, str, slot, luaH_getstr)) {
@@ -713,7 +715,7 @@ LUA_API int lua_geti (lua_State *L, int idx, lua_Integer n) {
}
-static int finishrawget (lua_State *L, const TValue *val) {
+l_sinline int finishrawget (lua_State *L, const TValue *val) {
if (isempty(val)) /* avoid copying empty items to the stack */
setnilvalue(s2v(L->top));
else