MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / luaS_new

Function luaS_new

src/vm/luavm/lua/lstring.c:201–211  ·  view source on GitHub ↗

** Create or reuse a zero-terminated string, first checking in the ** cache (using the string address as a key). The cache can contain ** only zero-terminated strings, so it is safe to use 'strcmp' to ** check hits. */

Source from the content-addressed store, hash-verified

199** check hits.
200*/
201TString *luaS_new (lua_State *L, const char *str) {
202 unsigned int i = point2uint(str) % STRCACHE_SIZE; /* hash */
203 TString **p = G(L)->strcache[i];
204 if (strcmp(str, getstr(p[0])) == 0) /* hit? */
205 return p[0]; /* that it is */
206 else { /* normal route */
207 TString *s = luaS_newlstr(L, str, strlen(str));
208 p[0] = s;
209 return s;
210 }
211}
212
213
214Udata *luaS_newudata (lua_State *L, size_t s) {

Callers 11

luaX_initFunction · 0.85
luaT_initFunction · 0.85
breaklabelFunction · 0.85
gotostatFunction · 0.85
luaY_parserFunction · 0.85
resume_errorFunction · 0.85
lua_pushstringFunction · 0.85
lua_getglobalFunction · 0.85
lua_getfieldFunction · 0.85
lua_setglobalFunction · 0.85
lua_setfieldFunction · 0.85

Calls 1

luaS_newlstrFunction · 0.85

Tested by

no test coverage detected