ruby-changes:12467
From: akr <ko1@a...>
Date: Fri, 17 Jul 2009 18:29:04 +0900 (JST)
Subject: [ruby-changes:12467] Ruby:r24167 (trunk): * range.c (recursive_hash): extracted from range_hash. reject
akr 2009-07-17 18:28:46 +0900 (Fri, 17 Jul 2009) New Revision: 24167 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=24167 Log: * range.c (recursive_hash): extracted from range_hash. reject recursive key. (range_hash): use recursive_hash. Modified files: trunk/ChangeLog trunk/range.c Index: ChangeLog =================================================================== --- ChangeLog (revision 24166) +++ ChangeLog (revision 24167) @@ -1,3 +1,9 @@ +Fri Jul 17 18:18:23 2009 Tanaka Akira <akr@f...> + + * range.c (recursive_hash): extracted from range_hash. reject + recursive key. + (range_hash): use recursive_hash. + Fri Jul 17 18:11:32 2009 Tanaka Akira <akr@f...> * struct.c (recursive_hash): extracted from rb_struct_hash. reject Index: range.c =================================================================== --- range.c (revision 24166) +++ range.c (revision 24167) @@ -201,21 +201,15 @@ return Qtrue; } -/* - * call-seq: - * rng.hash => fixnum - * - * Generate a hash value such that two ranges with the same start and - * end points, and the same value for the "exclude end" flag, generate - * the same hash value. - */ - static VALUE -range_hash(VALUE range) +recursive_hash(VALUE range, VALUE dummy, int recur) { unsigned long 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)); @@ -227,6 +221,21 @@ return LONG2FIX(hash); } +/* + * call-seq: + * rng.hash => fixnum + * + * Generate a hash value such that two ranges with the same start and + * end points, and the same value for the "exclude end" flag, generate + * the same hash value. + */ + +static VALUE +range_hash(VALUE range) +{ + return rb_exec_recursive(recursive_hash, range, 0); +} + static void range_each_func(VALUE range, VALUE (*func) (VALUE, void *), void *arg) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/