diff options
author | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-09-15 21:30:50 +0000 |
---|---|---|
committer | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-09-15 21:30:50 +0000 |
commit | 1796522f10e4bee3db8df77fa66f749084592285 (patch) | |
tree | 8efee8e6cc94d15eb0206a5837830290e4cfee22 /range.c | |
parent | 6a54d4b6fe2cc397716080a01394f75c6b6cfb4a (diff) |
* thread.c (rb_exec_recursive_outer, rb_exec_recursive): Added method to short-circuit to the outermost level in case of recursion
* test/ruby/test_thread.rb (test_recursive_outer): Test for above
* hash.c (rb_hash_hash): Return a sensible hash for in case of recursion [ruby-core:24648]
* range.c (rb_range_hash): ditto
* struct.c (rb_struct_hash): ditto
* array.c (rb_array_hash): ditto
* test/ruby/test_array.rb (test_hash2): test for above
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'range.c')
-rw-r--r-- | range.c | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -207,14 +207,13 @@ recursive_hash(VALUE range, VALUE dummy, int recur) st_index_t hash = EXCL(range); VALUE v; - if (recur) { - rb_raise(rb_eArgError, "recursive key for hash"); - } hash = rb_hash_start(hash); - v = rb_hash(RANGE_BEG(range)); - hash = rb_hash_uint(hash, NUM2LONG(v)); - v = rb_hash(RANGE_END(range)); - hash = rb_hash_uint(hash, NUM2LONG(v)); + if (!recur) { + v = rb_hash(RANGE_BEG(range)); + hash = rb_hash_uint(hash, NUM2LONG(v)); + v = rb_hash(RANGE_END(range)); + hash = rb_hash_uint(hash, NUM2LONG(v)); + } hash = rb_hash_uint(hash, EXCL(range) << 24); hash = rb_hash_end(hash); @@ -233,7 +232,7 @@ recursive_hash(VALUE range, VALUE dummy, int recur) static VALUE range_hash(VALUE range) { - return rb_exec_recursive(recursive_hash, range, 0); + return rb_exec_recursive_outer(recursive_hash, range, 0); } static void |