diff options
Diffstat (limited to 'lstring.c')
-rw-r--r-- | lstring.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstring.c,v 2.64 2018/02/15 18:06:24 roberto Exp roberto $ | 2 | ** $Id: lstring.c,v 2.65 2018/02/20 16:52:50 roberto Exp roberto $ |
3 | ** String table (keeps all strings handled by Lua) | 3 | ** String table (keeps all strings handled by Lua) |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -99,7 +99,7 @@ void luaS_resize (lua_State *L, int nsize) { | |||
99 | if (nsize < osize) /* shrinking table? */ | 99 | if (nsize < osize) /* shrinking table? */ |
100 | tablerehash(tb->hash, osize, nsize); /* depopulate shrinking part */ | 100 | tablerehash(tb->hash, osize, nsize); /* depopulate shrinking part */ |
101 | newvect = luaM_reallocvector(L, tb->hash, osize, nsize, TString*); | 101 | newvect = luaM_reallocvector(L, tb->hash, osize, nsize, TString*); |
102 | if (newvect == NULL) { /* reallocation failed? */ | 102 | if (unlikely(newvect == NULL)) { /* reallocation failed? */ |
103 | if (nsize < osize) /* was it shrinking table? */ | 103 | if (nsize < osize) /* was it shrinking table? */ |
104 | tablerehash(tb->hash, nsize, osize); /* restore to original size */ | 104 | tablerehash(tb->hash, nsize, osize); /* restore to original size */ |
105 | /* leave table as it was */ | 105 | /* leave table as it was */ |
@@ -182,7 +182,7 @@ void luaS_remove (lua_State *L, TString *ts) { | |||
182 | 182 | ||
183 | 183 | ||
184 | static void growstrtab (lua_State *L, stringtable *tb) { | 184 | static void growstrtab (lua_State *L, stringtable *tb) { |
185 | if (tb->nuse == MAX_INT) { /* too many strings? */ | 185 | if (unlikely(tb->nuse == MAX_INT)) { /* too many strings? */ |
186 | luaC_fullgc(L, 1); /* try to free some... */ | 186 | luaC_fullgc(L, 1); /* try to free some... */ |
187 | if (tb->nuse == MAX_INT) /* still too many? */ | 187 | if (tb->nuse == MAX_INT) /* still too many? */ |
188 | luaM_error(L); /* cannot even create a message... */ | 188 | luaM_error(L); /* cannot even create a message... */ |
@@ -233,7 +233,7 @@ TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { | |||
233 | return internshrstr(L, str, l); | 233 | return internshrstr(L, str, l); |
234 | else { | 234 | else { |
235 | TString *ts; | 235 | TString *ts; |
236 | if (l >= (MAX_SIZE - sizeof(TString))/sizeof(char)) | 236 | if (unlikely(l >= (MAX_SIZE - sizeof(TString))/sizeof(char))) |
237 | luaM_toobig(L); | 237 | luaM_toobig(L); |
238 | ts = luaS_createlngstrobj(L, l); | 238 | ts = luaS_createlngstrobj(L, l); |
239 | memcpy(getstr(ts), str, l * sizeof(char)); | 239 | memcpy(getstr(ts), str, l * sizeof(char)); |
@@ -269,7 +269,7 @@ Udata *luaS_newudata (lua_State *L, size_t s, int nuvalue) { | |||
269 | Udata *u; | 269 | Udata *u; |
270 | int i; | 270 | int i; |
271 | GCObject *o; | 271 | GCObject *o; |
272 | if (s > MAX_SIZE - udatamemoffset(nuvalue)) | 272 | if (unlikely(s > MAX_SIZE - udatamemoffset(nuvalue))) |
273 | luaM_toobig(L); | 273 | luaM_toobig(L); |
274 | o = luaC_newobj(L, LUA_TUSERDATA, sizeudata(nuvalue, s)); | 274 | o = luaC_newobj(L, LUA_TUSERDATA, sizeudata(nuvalue, s)); |
275 | u = gco2u(o); | 275 | u = gco2u(o); |