diff options
| author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-17 02:01:37 +0000 |
|---|---|---|
| committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-17 02:01:37 +0000 |
| commit | e643522940258e2746b436f0b1080ebc713f273b (patch) | |
| tree | 618499270d1403629fe085727ab6d481a234fae0 /string.c | |
| parent | 8bd4e2ea0b7ee3795be2b2a5e70fe67df6946727 (diff) | |
| download | ruby-e643522940258e2746b436f0b1080ebc713f273b.tar.gz ruby-e643522940258e2746b436f0b1080ebc713f273b.tar.xz ruby-e643522940258e2746b436f0b1080ebc713f273b.zip | |
* string.c (rb_str_hash): gets rid of collisions between different
encoding strings. [ruby-core:20526]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@20804 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
| -rw-r--r-- | string.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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 |
