summaryrefslogtreecommitdiff
path: root/struct.c
diff options
context:
space:
mode:
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);
}
/*