aboutsummaryrefslogtreecommitdiff
path: root/lauxlib.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2021-02-24 11:14:44 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2021-02-24 11:14:44 -0300
commit59c88f846d1dcd901a4420651aedf27816618923 (patch)
tree0e76a066c383cbc99cc2f60b8b4f97c5df45e479 /lauxlib.h
parentc03c527fd207b4ad8f5a8e0f4f2c176bd227c979 (diff)
downloadlua-59c88f846d1dcd901a4420651aedf27816618923.tar.gz
lua-59c88f846d1dcd901a4420651aedf27816618923.tar.bz2
lua-59c88f846d1dcd901a4420651aedf27816618923.zip
Broadening the use of branch hints
More uses of macros 'likely'/'unlikely' (renamed to 'l_likely'/'l_unlikely'), both in range (extended to the libraries) and in scope (extended to hooks, stack growth).
Diffstat (limited to 'lauxlib.h')
-rw-r--r--lauxlib.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/lauxlib.h b/lauxlib.h
index 65714911..9058e262 100644
--- a/lauxlib.h
+++ b/lauxlib.h
@@ -122,6 +122,10 @@ LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname,
122** =============================================================== 122** ===============================================================
123*/ 123*/
124 124
125#if !defined(l_likely)
126#define l_likely(x) x
127#endif
128
125 129
126#define luaL_newlibtable(L,l) \ 130#define luaL_newlibtable(L,l) \
127 lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1) 131 lua_createtable(L, 0, sizeof(l)/sizeof((l)[0]) - 1)
@@ -130,10 +134,10 @@ LUALIB_API void (luaL_requiref) (lua_State *L, const char *modname,
130 (luaL_checkversion(L), luaL_newlibtable(L,l), luaL_setfuncs(L,l,0)) 134 (luaL_checkversion(L), luaL_newlibtable(L,l), luaL_setfuncs(L,l,0))
131 135
132#define luaL_argcheck(L, cond,arg,extramsg) \ 136#define luaL_argcheck(L, cond,arg,extramsg) \
133 ((void)((cond) || luaL_argerror(L, (arg), (extramsg)))) 137 ((void)(l_likely(cond) || luaL_argerror(L, (arg), (extramsg))))
134 138
135#define luaL_argexpected(L,cond,arg,tname) \ 139#define luaL_argexpected(L,cond,arg,tname) \
136 ((void)((cond) || luaL_typeerror(L, (arg), (tname)))) 140 ((void)(l_likely(cond) || luaL_typeerror(L, (arg), (tname))))
137 141
138#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL)) 142#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL))
139#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL)) 143#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL))