From 8c85ad0519d1e876040ca3a606d28f29b21fdeb1 Mon Sep 17 00:00:00 2001 From: yugui Date: Wed, 17 Dec 2008 06:18:56 +0000 Subject: merges r20804 from trunk into ruby_1_9_1. * string.c (rb_str_hash): gets rid of collisions between different encoding strings. [ruby-core:20526] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- string.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'string.c') diff --git a/string.c b/string.c index 1eac1bda3c..e0efa04775 100644 --- a/string.c +++ b/string.c @@ -2014,7 +2014,11 @@ rb_memhash(const void *ptr, long len) int rb_str_hash(VALUE str) { - return rb_memhash((const void *)RSTRING_PTR(str), RSTRING_LEN(str)); + int e = ENCODING_GET(str); + if (e) { + if (rb_enc_str_asciionly_p(str)) e = 0; + } + return rb_memhash((const void *)RSTRING_PTR(str), RSTRING_LEN(str)) ^ e; } int -- cgit v1.2.3