mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 12:43:09 +00:00
mark all short string shared, see #1027
This commit is contained in:
@@ -75,7 +75,6 @@ void luaS_clearcache (global_State *g) {
|
|||||||
int i, j;
|
int i, j;
|
||||||
for (i = 0; i < STRCACHE_N; i++)
|
for (i = 0; i < STRCACHE_N; i++)
|
||||||
for (j = 0; j < STRCACHE_M; j++) {
|
for (j = 0; j < STRCACHE_M; j++) {
|
||||||
if (!isshared(g->strcache[i][j]) && iswhite(g->strcache[i][j])) /* will entry be collected? */
|
|
||||||
g->strcache[i][j] = g->memerrmsg; /* replace it with something fixed */
|
g->strcache[i][j] = g->memerrmsg; /* replace it with something fixed */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -936,6 +935,7 @@ new_string(unsigned int h, const char *str, lu_byte l) {
|
|||||||
memset(ts, 0, sz);
|
memset(ts, 0, sz);
|
||||||
setbits(ts->marked, WHITEBITS);
|
setbits(ts->marked, WHITEBITS);
|
||||||
gray2black(ts);
|
gray2black(ts);
|
||||||
|
makeshared(ts);
|
||||||
ts->tt = LUA_TSHRSTR;
|
ts->tt = LUA_TSHRSTR;
|
||||||
ts->hash = h;
|
ts->hash = h;
|
||||||
ts->shrlen = l;
|
ts->shrlen = l;
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ mark_shared(lua_State *L) {
|
|||||||
case LUA_TSTRING: {
|
case LUA_TSTRING: {
|
||||||
const char *str = lua_tostring(L, idx);
|
const char *str = lua_tostring(L, idx);
|
||||||
TString *ts = (TString *)(str - sizeof(UTString));
|
TString *ts = (TString *)(str - sizeof(UTString));
|
||||||
if(ts->tt==LUA_TLNGSTR)
|
|
||||||
makeshared(ts);
|
makeshared(ts);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user