diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2021-02-24 11:14:44 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2021-02-24 11:14:44 -0300 |
commit | 59c88f846d1dcd901a4420651aedf27816618923 (patch) | |
tree | 0e76a066c383cbc99cc2f60b8b4f97c5df45e479 /lmathlib.c | |
parent | c03c527fd207b4ad8f5a8e0f4f2c176bd227c979 (diff) | |
download | lua-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 'lmathlib.c')
-rw-r--r-- | lmathlib.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -73,7 +73,7 @@ static int math_atan (lua_State *L) { | |||
73 | static int math_toint (lua_State *L) { | 73 | static int math_toint (lua_State *L) { |
74 | int valid; | 74 | int valid; |
75 | lua_Integer n = lua_tointegerx(L, 1, &valid); | 75 | lua_Integer n = lua_tointegerx(L, 1, &valid); |
76 | if (valid) | 76 | if (l_likely(valid)) |
77 | lua_pushinteger(L, n); | 77 | lua_pushinteger(L, n); |
78 | else { | 78 | else { |
79 | luaL_checkany(L, 1); | 79 | luaL_checkany(L, 1); |
@@ -175,7 +175,8 @@ static int math_log (lua_State *L) { | |||
175 | lua_Number base = luaL_checknumber(L, 2); | 175 | lua_Number base = luaL_checknumber(L, 2); |
176 | #if !defined(LUA_USE_C89) | 176 | #if !defined(LUA_USE_C89) |
177 | if (base == l_mathop(2.0)) | 177 | if (base == l_mathop(2.0)) |
178 | res = l_mathop(log2)(x); else | 178 | res = l_mathop(log2)(x); |
179 | else | ||
179 | #endif | 180 | #endif |
180 | if (base == l_mathop(10.0)) | 181 | if (base == l_mathop(10.0)) |
181 | res = l_mathop(log10)(x); | 182 | res = l_mathop(log10)(x); |