aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-06-15 14:01:12 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-06-15 14:01:12 -0300
commit18b0e8270de991556460c57b1e3d88b2df5965fc (patch)
treed7213c25d3c60c512b80c506273de1f17887f808
parent094880ef9ee5ef88d4298c6665f96ab233e460a5 (diff)
downloadlua-18b0e8270de991556460c57b1e3d88b2df5965fc.tar.gz
lua-18b0e8270de991556460c57b1e3d88b2df5965fc.tar.bz2
lua-18b0e8270de991556460c57b1e3d88b2df5965fc.zip
32 characteres are more than enough for a good hash
-rw-r--r--lstring.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lstring.c b/lstring.c
index c265d3d4..ac526838 100644
--- a/lstring.c
+++ b/lstring.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstring.c,v 1.37 2000/05/24 13:54:49 roberto Exp roberto $ 2** $Id: lstring.c,v 1.38 2000/06/12 13:52:05 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*/
@@ -37,7 +37,7 @@ void luaS_freeall (lua_State *L) {
37 37
38static unsigned long hash_s (const char *s, size_t l) { 38static unsigned long hash_s (const char *s, size_t l) {
39 unsigned long h = l; /* seed */ 39 unsigned long h = l; /* seed */
40 size_t step = (l>>6)|1; /* if string is too long, don't hash all its chars */ 40 size_t step = (l>>5)|1; /* if string is too long, don't hash all its chars */
41 for (; l>=step; l-=step) 41 for (; l>=step; l-=step)
42 h = h ^ ((h<<5)+(h>>2)+(unsigned char)*(s++)); 42 h = h ^ ((h<<5)+(h>>2)+(unsigned char)*(s++));
43 return h; 43 return h;