diff options
| -rw-r--r-- | lstring.c | 12 | ||||
| -rw-r--r-- | lstring.h | 3 |
2 files changed, 13 insertions, 2 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lstring.c,v 2.53 2015/09/22 14:18:24 roberto Exp roberto $ | 2 | ** $Id: lstring.c,v 2.54 2015/10/08 15:53:31 roberto Exp roberto $ |
| 3 | ** String table (keeps all strings handled by Lua) | 3 | ** String table (keeps all strings handled by Lua) |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -56,6 +56,16 @@ unsigned int luaS_hash (const char *str, size_t l, unsigned int seed) { | |||
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | 58 | ||
| 59 | unsigned int luaS_hashlongstr (TString *ts) { | ||
| 60 | lua_assert(ts->tt == LUA_TLNGSTR); | ||
| 61 | if (ts->extra == 0) { /* no hash? */ | ||
| 62 | ts->hash = luaS_hash(getstr(ts), ts->u.lnglen, ts->hash); | ||
| 63 | ts->extra = 1; /* now it has its hash */ | ||
| 64 | } | ||
| 65 | return ts->hash; | ||
| 66 | } | ||
| 67 | |||
| 68 | |||
| 59 | /* | 69 | /* |
| 60 | ** resizes the string table | 70 | ** resizes the string table |
| 61 | */ | 71 | */ |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lstring.h,v 1.59 2015/03/25 13:42:19 roberto Exp roberto $ | 2 | ** $Id: lstring.h,v 1.60 2015/09/08 15:41:05 roberto Exp roberto $ |
| 3 | ** String table (keep all strings handled by Lua) | 3 | ** String table (keep all strings handled by Lua) |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -34,6 +34,7 @@ | |||
| 34 | 34 | ||
| 35 | 35 | ||
| 36 | LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); | 36 | LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); |
| 37 | LUAI_FUNC unsigned int luaS_hashlongstr (TString *ts); | ||
| 37 | LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b); | 38 | LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b); |
| 38 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); | 39 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); |
| 39 | LUAI_FUNC void luaS_clearcache (global_State *g); | 40 | LUAI_FUNC void luaS_clearcache (global_State *g); |
