From e722ad99d5b0e6a9bb0249ff3d9c8cce28d3204e Mon Sep 17 00:00:00 2001 From: mame Date: Sat, 14 Feb 2009 19:55:34 +0000 Subject: * 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 --- struct.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'struct.c') 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); } /* -- cgit v1.2.3