|
@@ -36,7 +36,7 @@ int luaS_eqlngstr (TString *a, TString *b) {
|
|
lua_assert(a->tt == LUA_VLNGSTR && b->tt == LUA_VLNGSTR);
|
|
lua_assert(a->tt == LUA_VLNGSTR && b->tt == LUA_VLNGSTR);
|
|
return (a == b) || /* same instance or... */
|
|
return (a == b) || /* same instance or... */
|
|
((len == b->u.lnglen) && /* equal length and ... */
|
|
((len == b->u.lnglen) && /* equal length and ... */
|
|
- (memcmp(getstr(a), getstr(b), len) == 0)); /* equal contents */
|
|
|
|
|
|
+ (memcmp(getlngstr(a), getlngstr(b), len) == 0)); /* equal contents */
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -52,7 +52,7 @@ unsigned int luaS_hashlongstr (TString *ts) {
|
|
lua_assert(ts->tt == LUA_VLNGSTR);
|
|
lua_assert(ts->tt == LUA_VLNGSTR);
|
|
if (ts->extra == 0) { /* no hash? */
|
|
if (ts->extra == 0) { /* no hash? */
|
|
size_t len = ts->u.lnglen;
|
|
size_t len = ts->u.lnglen;
|
|
- ts->hash = luaS_hash(getstr(ts), len, ts->hash);
|
|
|
|
|
|
+ ts->hash = luaS_hash(getlngstr(ts), len, ts->hash);
|
|
ts->extra = 1; /* now it has its hash */
|
|
ts->extra = 1; /* now it has its hash */
|
|
}
|
|
}
|
|
return ts->hash;
|
|
return ts->hash;
|
|
@@ -157,6 +157,7 @@ static TString *createstrobj (lua_State *L, size_t l, int tag, unsigned int h) {
|
|
TString *luaS_createlngstrobj (lua_State *L, size_t l) {
|
|
TString *luaS_createlngstrobj (lua_State *L, size_t l) {
|
|
TString *ts = createstrobj(L, l, LUA_VLNGSTR, G(L)->seed);
|
|
TString *ts = createstrobj(L, l, LUA_VLNGSTR, G(L)->seed);
|
|
ts->u.lnglen = l;
|
|
ts->u.lnglen = l;
|
|
|
|
+ ts->shrlen = 0xFF; /* signals that it is a long string */
|
|
return ts;
|
|
return ts;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -193,7 +194,7 @@ static TString *internshrstr (lua_State *L, const char *str, size_t l) {
|
|
TString **list = &tb->hash[lmod(h, tb->size)];
|
|
TString **list = &tb->hash[lmod(h, tb->size)];
|
|
lua_assert(str != NULL); /* otherwise 'memcmp'/'memcpy' are undefined */
|
|
lua_assert(str != NULL); /* otherwise 'memcmp'/'memcpy' are undefined */
|
|
for (ts = *list; ts != NULL; ts = ts->u.hnext) {
|
|
for (ts = *list; ts != NULL; ts = ts->u.hnext) {
|
|
- if (l == ts->shrlen && (memcmp(str, getstr(ts), l * sizeof(char)) == 0)) {
|
|
|
|
|
|
+ if (l == ts->shrlen && (memcmp(str, getshrstr(ts), l * sizeof(char)) == 0)) {
|
|
/* found! */
|
|
/* found! */
|
|
if (isdead(g, ts)) /* dead (but not collected yet)? */
|
|
if (isdead(g, ts)) /* dead (but not collected yet)? */
|
|
changewhite(ts); /* resurrect it */
|
|
changewhite(ts); /* resurrect it */
|
|
@@ -206,7 +207,7 @@ static TString *internshrstr (lua_State *L, const char *str, size_t l) {
|
|
list = &tb->hash[lmod(h, tb->size)]; /* rehash with new size */
|
|
list = &tb->hash[lmod(h, tb->size)]; /* rehash with new size */
|
|
}
|
|
}
|
|
ts = createstrobj(L, l, LUA_VSHRSTR, h);
|
|
ts = createstrobj(L, l, LUA_VSHRSTR, h);
|
|
- memcpy(getstr(ts), str, l * sizeof(char));
|
|
|
|
|
|
+ memcpy(getshrstr(ts), str, l * sizeof(char));
|
|
ts->shrlen = cast_byte(l);
|
|
ts->shrlen = cast_byte(l);
|
|
ts->u.hnext = *list;
|
|
ts->u.hnext = *list;
|
|
*list = ts;
|
|
*list = ts;
|
|
@@ -226,7 +227,7 @@ TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
|
|
if (l_unlikely(l >= (MAX_SIZE - sizeof(TString))/sizeof(char)))
|
|
if (l_unlikely(l >= (MAX_SIZE - sizeof(TString))/sizeof(char)))
|
|
luaM_toobig(L);
|
|
luaM_toobig(L);
|
|
ts = luaS_createlngstrobj(L, l);
|
|
ts = luaS_createlngstrobj(L, l);
|
|
- memcpy(getstr(ts), str, l * sizeof(char));
|
|
|
|
|
|
+ memcpy(getlngstr(ts), str, l * sizeof(char));
|
|
return ts;
|
|
return ts;
|
|
}
|
|
}
|
|
}
|
|
}
|