summaryrefslogtreecommitdiff
path: root/libs/liblua/src/llex.c
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-04-03 16:49:51 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-04-03 16:49:51 +0300
commit24cc09ca79cf8d53e10e23b1103287f168570899 (patch)
tree2c78d9f116f861cab073d41cd0190e92eccfabc6 /libs/liblua/src/llex.c
parentdd212611826b7c44e8a3c6cd2209b46d7cd03177 (diff)
Revert "liblua: update to 5.4.3"
This reverts commit 875bc74fa5fe083ba0b5c5a785c53ec0f49b9a1b.
Diffstat (limited to 'libs/liblua/src/llex.c')
-rw-r--r--libs/liblua/src/llex.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/libs/liblua/src/llex.c b/libs/liblua/src/llex.c
index e99151787a..4b8dec9985 100644
--- a/libs/liblua/src/llex.c
+++ b/libs/liblua/src/llex.c
@@ -122,29 +122,26 @@ l_noret luaX_syntaxerror (LexState *ls, const char *msg) {
/*
-** Creates a new string and anchors it in scanner's table so that it
-** will not be collected until the end of the compilation; by that time
-** it should be anchored somewhere. It also internalizes long strings,
-** ensuring there is only one copy of each unique string. The table
-** here is used as a set: the string enters as the key, while its value
-** is irrelevant. We use the string itself as the value only because it
-** is a TValue readly available. Later, the code generation can change
-** this value.
+** creates a new string and anchors it in scanner's table so that
+** it will not be collected until the end of the compilation
+** (by that time it should be anchored somewhere)
*/
TString *luaX_newstring (LexState *ls, const char *str, size_t l) {
lua_State *L = ls->L;
+ TValue *o; /* entry for 'str' */
TString *ts = luaS_newlstr(L, str, l); /* create new string */
- const TValue *o = luaH_getstr(ls->h, ts);
- if (!ttisnil(o)) /* string already present? */
- ts = keystrval(nodefromval(o)); /* get saved copy */
- else { /* not in use yet */
- TValue *stv = s2v(L->top++); /* reserve stack space for string */
- setsvalue(L, stv, ts); /* temporarily anchor the string */
- luaH_finishset(L, ls->h, stv, o, stv); /* t[string] = string */
- /* table is not a metatable, so it does not need to invalidate cache */
+ setsvalue2s(L, L->top++, ts); /* temporarily anchor it in stack */
+ o = luaH_set(L, ls->h, s2v(L->top - 1));
+ if (isempty(o)) { /* not in use yet? */
+ /* boolean value does not need GC barrier;
+ table is not a metatable, so it does not need to invalidate cache */
+ setbtvalue(o); /* t[string] = true */
luaC_checkGC(L);
- L->top--; /* remove string from stack */
}
+ else { /* string already present */
+ ts = keystrval(nodefromval(o)); /* re-use value previously stored */
+ }
+ L->top--; /* remove string from stack */
return ts;
}