From 7c868916797db04bcfc17b90c43cb31fa025d361 Mon Sep 17 00:00:00 2001 From: knu Date: Sat, 1 Nov 2003 16:16:31 +0000 Subject: * string.c (rb_str_hash): Update the HASH_PERL alternative hash algorithm in sync with Perl 5.8. * st.c (strhash): Ditto. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@4886 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- st.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'st.c') diff --git a/st.c b/st.c index 1cc0e2f4d..753dce9a0 100644 --- a/st.c +++ b/st.c @@ -536,10 +536,14 @@ strhash(string) register int val = 0; while ((c = *string++) != '\0') { - val = val*33 + c; + val += c; + val += (val << 10); + val ^= (val >> 6); } + val += (val << 3); + val ^= (val >> 11); - return val + (val>>5); + return val + (val << 15); #else register int val = 0; -- cgit