From 6645bb2df44d4fc6c7aea8347a559357b657f80a Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 1 Jun 2015 13:34:37 -0300 Subject: 'strcache' elements as arrays of 1 element hints that cache can be n-way (instead of direct mapped) --- lstring.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'lstring.c') diff --git a/lstring.c b/lstring.c index 5af5050b..5788c9e6 100644 --- a/lstring.c +++ b/lstring.c @@ -1,5 +1,5 @@ /* -** $Id: lstring.c,v 2.47 2015/03/04 13:31:21 roberto Exp roberto $ +** $Id: lstring.c,v 2.48 2015/03/25 13:42:19 roberto Exp roberto $ ** String table (keeps all strings handled by Lua) ** See Copyright Notice in lua.h */ @@ -94,8 +94,8 @@ void luaS_resize (lua_State *L, int newsize) { void luaS_clearcache (global_State *g) { int i; for (i = 0; i < STRCACHE_SIZE; i++) { - if (iswhite(g->strcache[i])) /* will entry be collected? */ - g->strcache[i] = g->memerrmsg; /* replace it with something fixed */ + if (iswhite(g->strcache[i][0])) /* will entry be collected? */ + g->strcache[i][0] = g->memerrmsg; /* replace it with something fixed */ } } @@ -110,8 +110,8 @@ void luaS_init (lua_State *L) { /* pre-create memory-error message */ g->memerrmsg = luaS_newliteral(L, MEMERRMSG); luaC_fix(L, obj2gco(g->memerrmsg)); /* it should never be collected */ - for (i = 0; i < STRCACHE_SIZE; i++) - g->strcache[i] = g->memerrmsg; /* fill cache with valid strings */ + for (i = 0; i < STRCACHE_SIZE; i++) /* fill cache with valid strings */ + g->strcache[i][0] = g->memerrmsg; } @@ -200,12 +200,12 @@ TString *luaS_newlstr (lua_State *L, const char *str, size_t l) { */ TString *luaS_new (lua_State *L, const char *str) { unsigned int i = point2uint(str) % STRCACHE_SIZE; /* hash */ - TString **p = &G(L)->strcache[i]; - if (strcmp(str, getstr(*p)) == 0) /* hit? */ - return *p; /* that it is */ + TString **p = G(L)->strcache[i]; + if (strcmp(str, getstr(p[0])) == 0) /* hit? */ + return p[0]; /* that it is */ else { /* normal route */ TString *s = luaS_newlstr(L, str, strlen(str)); - *p = s; + p[0] = s; return s; } } -- cgit v1.2.3-55-g6feb