aboutsummaryrefslogtreecommitdiff
path: root/lbaselib.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lbaselib.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/lbaselib.c b/lbaselib.c
index 60786b3d..83ad306d 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -138,7 +138,7 @@ static int luaB_setmetatable (lua_State *L) {
138 int t = lua_type(L, 2); 138 int t = lua_type(L, 2);
139 luaL_checktype(L, 1, LUA_TTABLE); 139 luaL_checktype(L, 1, LUA_TTABLE);
140 luaL_argexpected(L, t == LUA_TNIL || t == LUA_TTABLE, 2, "nil or table"); 140 luaL_argexpected(L, t == LUA_TNIL || t == LUA_TTABLE, 2, "nil or table");
141 if (luaL_getmetafield(L, 1, "__metatable") != LUA_TNIL) 141 if (l_unlikely(luaL_getmetafield(L, 1, "__metatable") != LUA_TNIL))
142 return luaL_error(L, "cannot change a protected metatable"); 142 return luaL_error(L, "cannot change a protected metatable");
143 lua_settop(L, 2); 143 lua_settop(L, 2);
144 lua_setmetatable(L, 1); 144 lua_setmetatable(L, 1);
@@ -300,7 +300,7 @@ static int luaB_ipairs (lua_State *L) {
300 300
301 301
302static int load_aux (lua_State *L, int status, int envidx) { 302static int load_aux (lua_State *L, int status, int envidx) {
303 if (status == LUA_OK) { 303 if (l_likely(status == LUA_OK)) {
304 if (envidx != 0) { /* 'env' parameter? */ 304 if (envidx != 0) { /* 'env' parameter? */
305 lua_pushvalue(L, envidx); /* environment for loaded function */ 305 lua_pushvalue(L, envidx); /* environment for loaded function */
306 if (!lua_setupvalue(L, -2, 1)) /* set it as 1st upvalue */ 306 if (!lua_setupvalue(L, -2, 1)) /* set it as 1st upvalue */
@@ -356,7 +356,7 @@ static const char *generic_reader (lua_State *L, void *ud, size_t *size) {
356 *size = 0; 356 *size = 0;
357 return NULL; 357 return NULL;
358 } 358 }
359 else if (!lua_isstring(L, -1)) 359 else if (l_unlikely(!lua_isstring(L, -1)))
360 luaL_error(L, "reader function must return a string"); 360 luaL_error(L, "reader function must return a string");
361 lua_replace(L, RESERVEDSLOT); /* save string in reserved slot */ 361 lua_replace(L, RESERVEDSLOT); /* save string in reserved slot */
362 return lua_tolstring(L, RESERVEDSLOT, size); 362 return lua_tolstring(L, RESERVEDSLOT, size);
@@ -394,7 +394,7 @@ static int dofilecont (lua_State *L, int d1, lua_KContext d2) {
394static int luaB_dofile (lua_State *L) { 394static int luaB_dofile (lua_State *L) {
395 const char *fname = luaL_optstring(L, 1, NULL); 395 const char *fname = luaL_optstring(L, 1, NULL);
396 lua_settop(L, 1); 396 lua_settop(L, 1);
397 if (luaL_loadfile(L, fname) != LUA_OK) 397 if (l_unlikely(luaL_loadfile(L, fname) != LUA_OK))
398 return lua_error(L); 398 return lua_error(L);
399 lua_callk(L, 0, LUA_MULTRET, 0, dofilecont); 399 lua_callk(L, 0, LUA_MULTRET, 0, dofilecont);
400 return dofilecont(L, 0, 0); 400 return dofilecont(L, 0, 0);
@@ -402,7 +402,7 @@ static int luaB_dofile (lua_State *L) {
402 402
403 403
404static int luaB_assert (lua_State *L) { 404static int luaB_assert (lua_State *L) {
405 if (lua_toboolean(L, 1)) /* condition is true? */ 405 if (l_likely(lua_toboolean(L, 1))) /* condition is true? */
406 return lua_gettop(L); /* return all arguments */ 406 return lua_gettop(L); /* return all arguments */
407 else { /* error */ 407 else { /* error */
408 luaL_checkany(L, 1); /* there must be a condition */ 408 luaL_checkany(L, 1); /* there must be a condition */
@@ -438,7 +438,7 @@ static int luaB_select (lua_State *L) {
438** ignored). 438** ignored).
439*/ 439*/
440static int finishpcall (lua_State *L, int status, lua_KContext extra) { 440static int finishpcall (lua_State *L, int status, lua_KContext extra) {
441 if (status != LUA_OK && status != LUA_YIELD) { /* error? */ 441 if (l_unlikely(status != LUA_OK && status != LUA_YIELD)) { /* error? */
442 lua_pushboolean(L, 0); /* first result (false) */ 442 lua_pushboolean(L, 0); /* first result (false) */
443 lua_pushvalue(L, -2); /* error message */ 443 lua_pushvalue(L, -2); /* error message */
444 return 2; /* return false, msg */ 444 return 2; /* return false, msg */