summaryrefslogtreecommitdiff
path: root/struct.c
diff options
context:
space:
mode:
Diffstat (limited to 'struct.c')
-rw-r--r--struct.c34
1 files changed, 13 insertions, 21 deletions
diff --git a/struct.c b/struct.c
index bad339ffbb..6be512eaee 100644
--- a/struct.c
+++ b/struct.c
@@ -949,8 +949,15 @@ rb_struct_equal(VALUE s, VALUE s2)
return rb_exec_recursive_paired(recursive_equal, s, s2, s2);
}
+/*
+ * call-seq:
+ * struct.hash -> fixnum
+ *
+ * Returns a hash value based on this struct's contents (see Object#hash).
+ */
+
static VALUE
-recursive_hash(VALUE s, VALUE dummy, int recur)
+rb_struct_hash(VALUE s)
{
long i, len;
st_index_t h;
@@ -958,31 +965,16 @@ recursive_hash(VALUE s, VALUE dummy, int recur)
const VALUE *ptr;
h = rb_hash_start(rb_hash(rb_obj_class(s)));
- if (!recur) {
- ptr = RSTRUCT_CONST_PTR(s);
- len = RSTRUCT_LEN(s);
- for (i = 0; i < len; i++) {
- n = rb_hash(ptr[i]);
- h = rb_hash_uint(h, NUM2LONG(n));
- }
+ ptr = RSTRUCT_CONST_PTR(s);
+ len = RSTRUCT_LEN(s);
+ for (i = 0; i < len; i++) {
+ n = rb_hash(ptr[i]);
+ h = rb_hash_uint(h, NUM2LONG(n));
}
h = rb_hash_end(h);
return INT2FIX(h);
}
-/*
- * call-seq:
- * struct.hash -> fixnum
- *
- * Returns a hash value based on this struct's contents (see Object#hash).
- */
-
-static VALUE
-rb_struct_hash(VALUE s)
-{
- return rb_exec_recursive_paired(recursive_hash, s, s, 0);
-}
-
static VALUE
recursive_eql(VALUE s, VALUE s2, int recur)
{