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 /lstring.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 'lstring.c')
-rw-r--r-- | lstring.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -89,7 +89,7 @@ void luaS_resize (lua_State *L, int nsize) { | |||
89 | if (nsize < osize) /* shrinking table? */ | 89 | if (nsize < osize) /* shrinking table? */ |
90 | tablerehash(tb->hash, osize, nsize); /* depopulate shrinking part */ | 90 | tablerehash(tb->hash, osize, nsize); /* depopulate shrinking part */ |
91 | newvect = luaM_reallocvector(L, tb->hash, osize, nsize, TString*); | 91 | newvect = luaM_reallocvector(L, tb->hash, osize, nsize, TString*); |
92 | if (unlikely(newvect == NULL)) { /* reallocation failed? */ | 92 | if (l_unlikely(newvect == NULL)) { /* reallocation failed? */ |
93 | if (nsize < osize) /* was it shrinking table? */ | 93 | if (nsize < osize) /* was it shrinking table? */ |
94 | tablerehash(tb->hash, nsize, osize); /* restore to original size */ | 94 | tablerehash(tb->hash, nsize, osize); /* restore to original size */ |
95 | /* leave table as it was */ | 95 | /* leave table as it was */ |
@@ -172,7 +172,7 @@ void luaS_remove (lua_State *L, TString *ts) { | |||
172 | 172 | ||
173 | 173 | ||
174 | static void growstrtab (lua_State *L, stringtable *tb) { | 174 | static void growstrtab (lua_State *L, stringtable *tb) { |
175 | if (unlikely(tb->nuse == MAX_INT)) { /* too many strings? */ | 175 | if (l_unlikely(tb->nuse == MAX_INT)) { /* too many strings? */ |
176 | luaC_fullgc(L, 1); /* try to free some... */ | 176 | luaC_fullgc(L, 1); /* try to free some... */ |
177 | if (tb->nuse == MAX_INT) /* still too many? */ | 177 | if (tb->nuse == MAX_INT) /* still too many? */ |
178 | luaM_error(L); /* cannot even create a message... */ | 178 | luaM_error(L); /* cannot even create a message... */ |
@@ -223,7 +223,7 @@ TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { | |||
223 | return internshrstr(L, str, l); | 223 | return internshrstr(L, str, l); |
224 | else { | 224 | else { |
225 | TString *ts; | 225 | TString *ts; |
226 | if (unlikely(l >= (MAX_SIZE - sizeof(TString))/sizeof(char))) | 226 | if (l_unlikely(l >= (MAX_SIZE - sizeof(TString))/sizeof(char))) |
227 | luaM_toobig(L); | 227 | luaM_toobig(L); |
228 | ts = luaS_createlngstrobj(L, l); | 228 | ts = luaS_createlngstrobj(L, l); |
229 | memcpy(getstr(ts), str, l * sizeof(char)); | 229 | memcpy(getstr(ts), str, l * sizeof(char)); |
@@ -259,7 +259,7 @@ Udata *luaS_newudata (lua_State *L, size_t s, int nuvalue) { | |||
259 | Udata *u; | 259 | Udata *u; |
260 | int i; | 260 | int i; |
261 | GCObject *o; | 261 | GCObject *o; |
262 | if (unlikely(s > MAX_SIZE - udatamemoffset(nuvalue))) | 262 | if (l_unlikely(s > MAX_SIZE - udatamemoffset(nuvalue))) |
263 | luaM_toobig(L); | 263 | luaM_toobig(L); |
264 | o = luaC_newobj(L, LUA_VUSERDATA, sizeudata(nuvalue, s)); | 264 | o = luaC_newobj(L, LUA_VUSERDATA, sizeudata(nuvalue, s)); |
265 | u = gco2u(o); | 265 | u = gco2u(o); |