Internalized string "break" kept by the parser

The parser uses "break" as fake label to compile "break" as "goto
break". To avoid producing this string at each use, it keeps it
available in its state.
This commit is contained in:
Roberto Ierusalimschy
2025-05-15 12:43:37 -03:00
parent fded0b4a84
commit 3fb7a77731
3 changed files with 7 additions and 3 deletions

3
llex.c
View File

@@ -190,6 +190,9 @@ void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source,
ls->lastline = 1;
ls->source = source;
ls->envn = luaS_newliteral(L, LUA_ENV); /* get env name */
ls->brkn = luaS_newliteral(L, "break"); /* get "break" name */
/* "break" cannot be collected, as it is a reserved word" */
lua_assert(isreserved(ls->brkn));
luaZ_resizebuffer(ls->L, ls->buff, LUA_MINBUFFER); /* initialize buffer */
}