mirror of
https://github.com/lua/lua
synced 2026-09-27 00:28:25 +03:00
32 characteres are more than enough for a good hash
This commit is contained in:
parent
094880ef9e
commit
18b0e8270d
1 changed files with 2 additions and 2 deletions
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lstring.c,v 1.37 2000/05/24 13:54:49 roberto Exp roberto $
|
||||
** $Id: lstring.c,v 1.38 2000/06/12 13:52:05 roberto Exp roberto $
|
||||
** String table (keeps all strings handled by Lua)
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
|
@ -37,7 +37,7 @@ void luaS_freeall (lua_State *L) {
|
|||
|
||||
static unsigned long hash_s (const char *s, size_t l) {
|
||||
unsigned long h = l; /* seed */
|
||||
size_t step = (l>>6)|1; /* if string is too long, don't hash all its chars */
|
||||
size_t step = (l>>5)|1; /* if string is too long, don't hash all its chars */
|
||||
for (; l>=step; l-=step)
|
||||
h = h ^ ((h<<5)+(h>>2)+(unsigned char)*(s++));
|
||||
return h;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue