diff options
Diffstat (limited to 'lauxlib.c')
-rw-r--r-- | lauxlib.c | 22 |
1 files changed, 11 insertions, 11 deletions
@@ -190,7 +190,7 @@ LUALIB_API int luaL_argerror (lua_State *L, int arg, const char *extramsg) { | |||
190 | } | 190 | } |
191 | 191 | ||
192 | 192 | ||
193 | int luaL_typeerror (lua_State *L, int arg, const char *tname) { | 193 | LUALIB_API int luaL_typeerror (lua_State *L, int arg, const char *tname) { |
194 | const char *msg; | 194 | const char *msg; |
195 | const char *typearg; /* name for the type of the actual argument */ | 195 | const char *typearg; /* name for the type of the actual argument */ |
196 | if (luaL_getmetafield(L, arg, "__name") == LUA_TSTRING) | 196 | if (luaL_getmetafield(L, arg, "__name") == LUA_TSTRING) |
@@ -378,7 +378,7 @@ LUALIB_API int luaL_checkoption (lua_State *L, int arg, const char *def, | |||
378 | ** but without 'msg'.) | 378 | ** but without 'msg'.) |
379 | */ | 379 | */ |
380 | LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *msg) { | 380 | LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *msg) { |
381 | if (!lua_checkstack(L, space)) { | 381 | if (l_unlikely(!lua_checkstack(L, space))) { |
382 | if (msg) | 382 | if (msg) |
383 | luaL_error(L, "stack overflow (%s)", msg); | 383 | luaL_error(L, "stack overflow (%s)", msg); |
384 | else | 384 | else |
@@ -388,20 +388,20 @@ LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *msg) { | |||
388 | 388 | ||
389 | 389 | ||
390 | LUALIB_API void luaL_checktype (lua_State *L, int arg, int t) { | 390 | LUALIB_API void luaL_checktype (lua_State *L, int arg, int t) { |
391 | if (lua_type(L, arg) != t) | 391 | if (l_unlikely(lua_type(L, arg) != t)) |
392 | tag_error(L, arg, t); | 392 | tag_error(L, arg, t); |
393 | } | 393 | } |
394 | 394 | ||
395 | 395 | ||
396 | LUALIB_API void luaL_checkany (lua_State *L, int arg) { | 396 | LUALIB_API void luaL_checkany (lua_State *L, int arg) { |
397 | if (lua_type(L, arg) == LUA_TNONE) | 397 | if (l_unlikely(lua_type(L, arg) == LUA_TNONE)) |
398 | luaL_argerror(L, arg, "value expected"); | 398 | luaL_argerror(L, arg, "value expected"); |
399 | } | 399 | } |
400 | 400 | ||
401 | 401 | ||
402 | LUALIB_API const char *luaL_checklstring (lua_State *L, int arg, size_t *len) { | 402 | LUALIB_API const char *luaL_checklstring (lua_State *L, int arg, size_t *len) { |
403 | const char *s = lua_tolstring(L, arg, len); | 403 | const char *s = lua_tolstring(L, arg, len); |
404 | if (!s) tag_error(L, arg, LUA_TSTRING); | 404 | if (l_unlikely(!s)) tag_error(L, arg, LUA_TSTRING); |
405 | return s; | 405 | return s; |
406 | } | 406 | } |
407 | 407 | ||
@@ -420,7 +420,7 @@ LUALIB_API const char *luaL_optlstring (lua_State *L, int arg, | |||
420 | LUALIB_API lua_Number luaL_checknumber (lua_State *L, int arg) { | 420 | LUALIB_API lua_Number luaL_checknumber (lua_State *L, int arg) { |
421 | int isnum; | 421 | int isnum; |
422 | lua_Number d = lua_tonumberx(L, arg, &isnum); | 422 | lua_Number d = lua_tonumberx(L, arg, &isnum); |
423 | if (!isnum) | 423 | if (l_unlikely(!isnum)) |
424 | tag_error(L, arg, LUA_TNUMBER); | 424 | tag_error(L, arg, LUA_TNUMBER); |
425 | return d; | 425 | return d; |
426 | } | 426 | } |
@@ -442,7 +442,7 @@ static void interror (lua_State *L, int arg) { | |||
442 | LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int arg) { | 442 | LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int arg) { |
443 | int isnum; | 443 | int isnum; |
444 | lua_Integer d = lua_tointegerx(L, arg, &isnum); | 444 | lua_Integer d = lua_tointegerx(L, arg, &isnum); |
445 | if (!isnum) { | 445 | if (l_unlikely(!isnum)) { |
446 | interror(L, arg); | 446 | interror(L, arg); |
447 | } | 447 | } |
448 | return d; | 448 | return d; |
@@ -475,7 +475,7 @@ static void *resizebox (lua_State *L, int idx, size_t newsize) { | |||
475 | lua_Alloc allocf = lua_getallocf(L, &ud); | 475 | lua_Alloc allocf = lua_getallocf(L, &ud); |
476 | UBox *box = (UBox *)lua_touserdata(L, idx); | 476 | UBox *box = (UBox *)lua_touserdata(L, idx); |
477 | void *temp = allocf(ud, box->box, box->bsize, newsize); | 477 | void *temp = allocf(ud, box->box, box->bsize, newsize); |
478 | if (temp == NULL && newsize > 0) { /* allocation error? */ | 478 | if (l_unlikely(temp == NULL && newsize > 0)) { /* allocation error? */ |
479 | lua_pushliteral(L, "not enough memory"); | 479 | lua_pushliteral(L, "not enough memory"); |
480 | lua_error(L); /* raise a memory error */ | 480 | lua_error(L); /* raise a memory error */ |
481 | } | 481 | } |
@@ -521,7 +521,7 @@ static void newbox (lua_State *L) { | |||
521 | */ | 521 | */ |
522 | static size_t newbuffsize (luaL_Buffer *B, size_t sz) { | 522 | static size_t newbuffsize (luaL_Buffer *B, size_t sz) { |
523 | size_t newsize = B->size * 2; /* double buffer size */ | 523 | size_t newsize = B->size * 2; /* double buffer size */ |
524 | if (MAX_SIZET - sz < B->n) /* overflow in (B->n + sz)? */ | 524 | if (l_unlikely(MAX_SIZET - sz < B->n)) /* overflow in (B->n + sz)? */ |
525 | return luaL_error(B->L, "buffer too large"); | 525 | return luaL_error(B->L, "buffer too large"); |
526 | if (newsize < B->n + sz) /* double is not big enough? */ | 526 | if (newsize < B->n + sz) /* double is not big enough? */ |
527 | newsize = B->n + sz; | 527 | newsize = B->n + sz; |
@@ -861,7 +861,7 @@ LUALIB_API lua_Integer luaL_len (lua_State *L, int idx) { | |||
861 | int isnum; | 861 | int isnum; |
862 | lua_len(L, idx); | 862 | lua_len(L, idx); |
863 | l = lua_tointegerx(L, -1, &isnum); | 863 | l = lua_tointegerx(L, -1, &isnum); |
864 | if (!isnum) | 864 | if (l_unlikely(!isnum)) |
865 | luaL_error(L, "object length is not an integer"); | 865 | luaL_error(L, "object length is not an integer"); |
866 | lua_pop(L, 1); /* remove object */ | 866 | lua_pop(L, 1); /* remove object */ |
867 | return l; | 867 | return l; |
@@ -1074,7 +1074,7 @@ static void warnfon (void *ud, const char *message, int tocont) { | |||
1074 | 1074 | ||
1075 | LUALIB_API lua_State *luaL_newstate (void) { | 1075 | LUALIB_API lua_State *luaL_newstate (void) { |
1076 | lua_State *L = lua_newstate(l_alloc, NULL); | 1076 | lua_State *L = lua_newstate(l_alloc, NULL); |
1077 | if (L) { | 1077 | if (l_likely(L)) { |
1078 | lua_atpanic(L, &panic); | 1078 | lua_atpanic(L, &panic); |
1079 | lua_setwarnf(L, warnfoff, L); /* default is warnings off */ | 1079 | lua_setwarnf(L, warnfoff, L); /* default is warnings off */ |
1080 | } | 1080 | } |