aboutsummaryrefslogtreecommitdiffstats
path: root/struct.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-03 13:18:30 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-03 13:18:30 +0000
commit6f2efe84fb6169a03ed191606935a40640d6764c (patch)
treec32c3b4d48daeafb526c4e8d37fe0e9870956129 /struct.c
parentc7159e81fc0d70b67358deaa39d21babbc3d89e7 (diff)
downloadruby-6f2efe84fb6169a03ed191606935a40640d6764c.tar.gz
hash.c: detect recursion for all
* hash.c (rb_hash): detect recursion for all `hash' methods. each `hash' methods no longer need to use rb_exec_recursive(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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)
{