aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-07-27 14:06:17 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1998-07-27 14:06:17 -0300
commit894a2646719006489800ea68b0515ab956f8aa62 (patch)
tree45fc9b5d7fc553b505a1405f46edc46005ce9bc4
parente1a127245d3d977945819240a2df90ceb8ae516f (diff)
downloadlua-894a2646719006489800ea68b0515ab956f8aa62.tar.gz
lua-894a2646719006489800ea68b0515ab956f8aa62.tar.bz2
lua-894a2646719006489800ea68b0515ab956f8aa62.zip
new hash function.
-rw-r--r--lstring.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lstring.c b/lstring.c
index b2b4baa2..11303877 100644
--- a/lstring.c
+++ b/lstring.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstring.c,v 1.12 1998/03/06 16:54:42 roberto Exp roberto $ 2** $Id: lstring.c,v 1.13 1998/06/19 16:14:09 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*/
@@ -39,9 +39,9 @@ void luaS_init (void)
39 39
40static unsigned long hash_s (char *s, long l) 40static unsigned long hash_s (char *s, long l)
41{ 41{
42 unsigned long h = 0; 42 unsigned long h = 0; /* seed */
43 while (l--) 43 while (l--)
44 h = ((h<<5)-h)^(unsigned char)*(s++); 44 h = h ^ ((h<<5)+(h>>2)+(unsigned char)*(s++));
45 return h; 45 return h;
46} 46}
47 47