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 /loslib.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 'loslib.c')
-rw-r--r-- | loslib.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -170,7 +170,7 @@ static int os_tmpname (lua_State *L) { | |||
170 | char buff[LUA_TMPNAMBUFSIZE]; | 170 | char buff[LUA_TMPNAMBUFSIZE]; |
171 | int err; | 171 | int err; |
172 | lua_tmpnam(buff, err); | 172 | lua_tmpnam(buff, err); |
173 | if (err) | 173 | if (l_unlikely(err)) |
174 | return luaL_error(L, "unable to generate a unique filename"); | 174 | return luaL_error(L, "unable to generate a unique filename"); |
175 | lua_pushstring(L, buff); | 175 | lua_pushstring(L, buff); |
176 | return 1; | 176 | return 1; |
@@ -208,7 +208,7 @@ static int os_clock (lua_State *L) { | |||
208 | */ | 208 | */ |
209 | static void setfield (lua_State *L, const char *key, int value, int delta) { | 209 | static void setfield (lua_State *L, const char *key, int value, int delta) { |
210 | #if (defined(LUA_NUMTIME) && LUA_MAXINTEGER <= INT_MAX) | 210 | #if (defined(LUA_NUMTIME) && LUA_MAXINTEGER <= INT_MAX) |
211 | if (value > LUA_MAXINTEGER - delta) | 211 | if (l_unlikely(value > LUA_MAXINTEGER - delta)) |
212 | luaL_error(L, "field '%s' is out-of-bound", key); | 212 | luaL_error(L, "field '%s' is out-of-bound", key); |
213 | #endif | 213 | #endif |
214 | lua_pushinteger(L, (lua_Integer)value + delta); | 214 | lua_pushinteger(L, (lua_Integer)value + delta); |
@@ -253,9 +253,9 @@ static int getfield (lua_State *L, const char *key, int d, int delta) { | |||
253 | int t = lua_getfield(L, -1, key); /* get field and its type */ | 253 | int t = lua_getfield(L, -1, key); /* get field and its type */ |
254 | lua_Integer res = lua_tointegerx(L, -1, &isnum); | 254 | lua_Integer res = lua_tointegerx(L, -1, &isnum); |
255 | if (!isnum) { /* field is not an integer? */ | 255 | if (!isnum) { /* field is not an integer? */ |
256 | if (t != LUA_TNIL) /* some other value? */ | 256 | if (l_unlikely(t != LUA_TNIL)) /* some other value? */ |
257 | return luaL_error(L, "field '%s' is not an integer", key); | 257 | return luaL_error(L, "field '%s' is not an integer", key); |
258 | else if (d < 0) /* absent field; no default? */ | 258 | else if (l_unlikely(d < 0)) /* absent field; no default? */ |
259 | return luaL_error(L, "field '%s' missing in date table", key); | 259 | return luaL_error(L, "field '%s' missing in date table", key); |
260 | res = d; | 260 | res = d; |
261 | } | 261 | } |