summaryrefslogtreecommitdiff
path: root/struct.c
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-14 19:55:34 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-14 19:55:34 +0000
commite722ad99d5b0e6a9bb0249ff3d9c8cce28d3204e (patch)
tree704a4bf758367e8c8b7100dd0cb2c5e8dd26c6b9 /struct.c
parenta48f90b05b654cc98727a91c5fd9952c5a86221c (diff)
* string.c (rb_hash_uint32, rb_hash_uint, rb_hash_start, rb_hash_end),
include/ruby/intern.h: add Murmurhash API. [ruby-dev:37784] * complex.c (nucomp_hash), array.c (rb_ary_hash), time.c (time_hash), string.c (rb_str_hsah), object.c (rb_obj_hash), range.c (range_hash), struct.c (rb_struct_hash), hash.c (rb_any_hash), rational.c (nurat_hash): use Murmurhash. [ruby-dev:37784] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22317 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'struct.c')
-rw-r--r--struct.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/struct.c b/struct.c
index 0cc836123f..838830aa69 100644
--- a/struct.c
+++ b/struct.c
@@ -804,16 +804,17 @@ rb_struct_equal(VALUE s, VALUE s2)
static VALUE
rb_struct_hash(VALUE s)
{
- long i, h;
+ long i;
+ unsigned h;
VALUE n;
- h = rb_hash(rb_obj_class(s));
+ h = rb_hash_start(rb_hash(rb_obj_class(s)));
for (i = 0; i < RSTRUCT_LEN(s); i++) {
- h = (h << 1) | (h<0 ? 1 : 0);
n = rb_hash(RSTRUCT_PTR(s)[i]);
- h ^= NUM2LONG(n);
+ h = rb_hash_uint(h, NUM2LONG(n));
}
- return LONG2FIX(h);
+ h = rb_hash_end(h);
+ return INT2FIX(h);
}
/*