diff options
| author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-08-30 03:02:35 +0000 |
|---|---|---|
| committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-08-30 03:02:35 +0000 |
| commit | 0964b60f917392f7a827b3b2090cc2188d08f1fd (patch) | |
| tree | 0b91be76f32fef5a10f318ed789117290ed6290f /string.c | |
| parent | 969db0d06338570eff4f25778fe20a3e23369e54 (diff) | |
| download | ruby-0964b60f917392f7a827b3b2090cc2188d08f1fd.tar.gz ruby-0964b60f917392f7a827b3b2090cc2188d08f1fd.tar.xz ruby-0964b60f917392f7a827b3b2090cc2188d08f1fd.zip | |
* numeric.c (flo_hash): improve collision.
* string.c (rb_memhash): new generic function to calculate hash value
for memory chunk.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@10798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
| -rw-r--r-- | string.c | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -768,9 +768,9 @@ rb_str_concat(VALUE str1, VALUE str2) /* * hash_32 - 32 bit Fowler/Noll/Vo FNV-1a hash code * - * @(#) $Revision$ - * @(#) $Id$ - * @(#) $Source$ + * @(#) $hash_32.Revision: 1.1 $ + * @(#) $hash_32.Id: hash_32a.c,v 1.1 2003/10/03 20:38:53 chongo Exp $ + * @(#) $hash_32.Source: /usr/local/src/cmd/fnv/RCS/hash_32a.c,v $ * *** * @@ -841,10 +841,9 @@ rb_str_concat(VALUE str1, VALUE str2) #define FNV_32_PRIME 0x01000193 int -rb_str_hash(VALUE str) +rb_memhash(const void *ptr, long len) { - register long len = RSTRING(str)->len; - register char *p = RSTRING(str)->ptr; + register const unsigned char *p = ptr; register unsigned int hval = FNV1_32A_INIT; /* @@ -864,6 +863,12 @@ rb_str_hash(VALUE str) return hval; } +int +rb_str_hash(VALUE str) +{ + return rb_memhash(RSTRING(str)->ptr, RSTRING(str)->len); +} + /* * call-seq: * str.hash => fixnum |
