aboutsummaryrefslogtreecommitdiff
path: root/lstring.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-02-15 16:06:24 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-02-15 16:06:24 -0200
commitc7a8cba74512a16aa01a99f2cdf395b358ada2fc (patch)
tree00d54a7a1170f700470554984c30132972f04cbd /lstring.c
parent0682fe816929da2e5abe8e191ad9c8509e6bfc12 (diff)
downloadlua-c7a8cba74512a16aa01a99f2cdf395b358ada2fc.tar.gz
lua-c7a8cba74512a16aa01a99f2cdf395b358ada2fc.tar.bz2
lua-c7a8cba74512a16aa01a99f2cdf395b358ada2fc.zip
no more 'nfield' string
Diffstat (limited to 'lstring.c')
-rw-r--r--lstring.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/lstring.c b/lstring.c
index f22ac5b8..fbc3e02d 100644
--- a/lstring.c
+++ b/lstring.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstring.c,v 2.62 2017/12/18 13:00:57 roberto Exp roberto $ 2** $Id: lstring.c,v 2.63 2018/01/28 15:13:26 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*/
@@ -122,7 +122,7 @@ void luaS_clearcache (global_State *g) {
122 for (i = 0; i < STRCACHE_N; i++) 122 for (i = 0; i < STRCACHE_N; i++)
123 for (j = 0; j < STRCACHE_M; j++) { 123 for (j = 0; j < STRCACHE_M; j++) {
124 if (iswhite(g->strcache[i][j])) /* will entry be collected? */ 124 if (iswhite(g->strcache[i][j])) /* will entry be collected? */
125 g->strcache[i][j] = g->nfield; /* replace it with something fixed */ 125 g->strcache[i][j] = g->memerrmsg; /* replace it with something fixed */
126 } 126 }
127} 127}
128 128
@@ -133,19 +133,16 @@ void luaS_clearcache (global_State *g) {
133void luaS_init (lua_State *L) { 133void luaS_init (lua_State *L) {
134 global_State *g = G(L); 134 global_State *g = G(L);
135 int i, j; 135 int i, j;
136 TString *memerrmsg;
137 stringtable *tb = &G(L)->strt; 136 stringtable *tb = &G(L)->strt;
138 tb->hash = luaM_newvector(L, MINSTRTABSIZE, TString*); 137 tb->hash = luaM_newvector(L, MINSTRTABSIZE, TString*);
139 tablerehash(tb->hash, 0, MINSTRTABSIZE); /* clear array */ 138 tablerehash(tb->hash, 0, MINSTRTABSIZE); /* clear array */
140 tb->size = MINSTRTABSIZE; 139 tb->size = MINSTRTABSIZE;
141 /* pre-create memory-error message */ 140 /* pre-create memory-error message */
142 memerrmsg = luaS_newliteral(L, MEMERRMSG); 141 g->memerrmsg = luaS_newliteral(L, MEMERRMSG);
143 luaC_fix(L, obj2gco(memerrmsg)); /* it should never be collected */ 142 luaC_fix(L, obj2gco(g->memerrmsg)); /* it should never be collected */
144 g->nfield = luaS_newliteral(L, "n"); /* pre-create "n" field name */
145 luaC_fix(L, obj2gco(g->nfield)); /* it also should never be collected */
146 for (i = 0; i < STRCACHE_N; i++) /* fill cache with valid strings */ 143 for (i = 0; i < STRCACHE_N; i++) /* fill cache with valid strings */
147 for (j = 0; j < STRCACHE_M; j++) 144 for (j = 0; j < STRCACHE_M; j++)
148 g->strcache[i][j] = g->nfield; 145 g->strcache[i][j] = g->memerrmsg;
149} 146}
150 147
151 148