new function 'luaS_hashlongstr'

This commit is contained in:
Roberto Ierusalimschy
2015-11-03 13:36:01 -02:00
parent e61ee8a036
commit d356183402
2 changed files with 13 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
/*
** $Id: lstring.c,v 2.53 2015/09/22 14:18:24 roberto Exp roberto $
** $Id: lstring.c,v 2.54 2015/10/08 15:53:31 roberto Exp roberto $
** String table (keeps all strings handled by Lua)
** See Copyright Notice in lua.h
*/
@@ -56,6 +56,16 @@ unsigned int luaS_hash (const char *str, size_t l, unsigned int seed) {
}
unsigned int luaS_hashlongstr (TString *ts) {
lua_assert(ts->tt == LUA_TLNGSTR);
if (ts->extra == 0) { /* no hash? */
ts->hash = luaS_hash(getstr(ts), ts->u.lnglen, ts->hash);
ts->extra = 1; /* now it has its hash */
}
return ts->hash;
}
/*
** resizes the string table
*/