diff options
author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-11-01 16:16:31 +0000 |
---|---|---|
committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-11-01 16:16:31 +0000 |
commit | 7c868916797db04bcfc17b90c43cb31fa025d361 (patch) | |
tree | 29db2cd02a6139cde66ebee2ad7fe75f39a86dae | |
parent | dca6d3ec48d2bc2700111a4b72955184c2cc4660 (diff) | |
download | ruby-7c868916797db04bcfc17b90c43cb31fa025d361.tar.gz ruby-7c868916797db04bcfc17b90c43cb31fa025d361.tar.xz ruby-7c868916797db04bcfc17b90c43cb31fa025d361.zip |
* 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
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | st.c | 8 | ||||
-rw-r--r-- | string.c | 8 |
3 files changed, 19 insertions, 4 deletions
@@ -1,3 +1,10 @@ +Sun Nov 2 01:02:04 2003 Akinori MUSHA <knu@iDaemons.org> + + * string.c (rb_str_hash): Update the HASH_PERL alternative hash + algorithm in sync with Perl 5.8. + + * st.c (strhash): Ditto. + Sat Nov 1 18:21:09 2003 GOTOU Yuuzou <gotoyuzo@notwork.org> * ext/openssl/ossl_ssl.c (ossl_ssl_peer_cert_chain): add new method @@ -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; @@ -744,9 +744,13 @@ rb_str_hash(str) } #elif HASH_PERL while (len--) { - key = key*33 + *p++; + key += *p++; + key += (key << 10); + key ^= (key >> 6); } - key = key + (key>>5); + key += (key << 3); + key ^= (key >> 11); + key += (key << 15); #else while (len--) { key = key*65599 + *p; |