aboutsummaryrefslogtreecommitdiff
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-2ff34717227b8046b0fdcb96206f11f5e888664e.tar.gz
lua-2ff34717227b8046b0fdcb96206f11f5e888664e.tar.bz2
lua-2ff34717227b8046b0fdcb96206f11f5e888664e.zip
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) {
86 } 86 }
87} 87}
88 88
89
90
89/* 91/*
90** Convert a valid actual index (not a pseudo-index) to its address. 92** Convert a valid actual index (not a pseudo-index) to its address.
91*/ 93*/
92static StkId index2stack (lua_State *L, int idx) { 94l_sinline StkId index2stack (lua_State *L, int idx) {
93 CallInfo *ci = L->ci; 95 CallInfo *ci = L->ci;
94 if (idx > 0) { 96 if (idx > 0) {
95 StkId o = ci->func + idx; 97 StkId o = ci->func + idx;
@@ -226,7 +228,7 @@ LUA_API void lua_closeslot (lua_State *L, int idx) {
226** Note that we move(copy) only the value inside the stack. 228** Note that we move(copy) only the value inside the stack.
227** (We do not move additional fields that may exist.) 229** (We do not move additional fields that may exist.)
228*/ 230*/
229static void reverse (lua_State *L, StkId from, StkId to) { 231l_sinline void reverse (lua_State *L, StkId from, StkId to) {
230 for (; from < to; from++, to--) { 232 for (; from < to; from++, to--) {
231 TValue temp; 233 TValue temp;
232 setobj(L, &temp, s2v(from)); 234 setobj(L, &temp, s2v(from));
@@ -446,7 +448,7 @@ LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) {
446} 448}
447 449
448 450
449static void *touserdata (const TValue *o) { 451l_sinline void *touserdata (const TValue *o) {
450 switch (ttype(o)) { 452 switch (ttype(o)) {
451 case LUA_TUSERDATA: return getudatamem(uvalue(o)); 453 case LUA_TUSERDATA: return getudatamem(uvalue(o));
452 case LUA_TLIGHTUSERDATA: return pvalue(o); 454 case LUA_TLIGHTUSERDATA: return pvalue(o);
@@ -638,7 +640,7 @@ LUA_API int lua_pushthread (lua_State *L) {
638*/ 640*/
639 641
640 642
641static int auxgetstr (lua_State *L, const TValue *t, const char *k) { 643l_sinline int auxgetstr (lua_State *L, const TValue *t, const char *k) {
642 const TValue *slot; 644 const TValue *slot;
643 TString *str = luaS_new(L, k); 645 TString *str = luaS_new(L, k);
644 if (luaV_fastget(L, t, str, slot, luaH_getstr)) { 646 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) {
713} 715}
714 716
715 717
716static int finishrawget (lua_State *L, const TValue *val) { 718l_sinline int finishrawget (lua_State *L, const TValue *val) {
717 if (isempty(val)) /* avoid copying empty items to the stack */ 719 if (isempty(val)) /* avoid copying empty items to the stack */
718 setnilvalue(s2v(L->top)); 720 setnilvalue(s2v(L->top));
719 else 721 else