Short strings can be external, too
That complicates a little object equality (and therefore table access for long strings), but the old behavior was somewhat weird. (Short strings, a concept otherwise absent from the manual, could not be external.)
This commit is contained in:
6
ltests.c
6
ltests.c
@@ -1066,8 +1066,12 @@ static int tracegc (lua_State *L) {
|
||||
|
||||
static int hash_query (lua_State *L) {
|
||||
if (lua_isnone(L, 2)) {
|
||||
TString *ts;
|
||||
luaL_argcheck(L, lua_type(L, 1) == LUA_TSTRING, 1, "string expected");
|
||||
lua_pushinteger(L, cast_int(tsvalue(obj_at(L, 1))->hash));
|
||||
ts = tsvalue(obj_at(L, 1));
|
||||
if (ts->tt == LUA_VLNGSTR)
|
||||
luaS_hashlongstr(ts); /* make sure long string has a hash */
|
||||
lua_pushinteger(L, cast_int(ts->hash));
|
||||
}
|
||||
else {
|
||||
TValue *o = obj_at(L, 1);
|
||||
|
||||
Reference in New Issue
Block a user