diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-05-11 14:19:41 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-05-11 14:19:41 +0000 |
commit | f54583220d0e0ce1a121852ed29e941511ff50c8 (patch) | |
tree | b8e120abff77d8b63a2353d516359078130a9b20 /enum.c | |
parent | 5c35dd6d650b76b742e67ec11bbdf1aae9e11a4e (diff) | |
download | ruby-f54583220d0e0ce1a121852ed29e941511ff50c8.tar.gz ruby-f54583220d0e0ce1a121852ed29e941511ff50c8.tar.xz ruby-f54583220d0e0ce1a121852ed29e941511ff50c8.zip |
* enum.c (all_iter_i, any_iter_i): reduced duplicated code.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@16366 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enum.c')
-rw-r--r-- | enum.c | 24 |
1 files changed, 8 insertions, 16 deletions
@@ -762,9 +762,9 @@ enum_sort_by(VALUE obj) } static VALUE -all_iter_i(VALUE i, VALUE *memo) +all_i(VALUE i, VALUE *memo) { - if (!RTEST(rb_yield(i))) { + if (!RTEST(i)) { *memo = Qfalse; rb_iter_break(); } @@ -772,13 +772,9 @@ all_iter_i(VALUE i, VALUE *memo) } static VALUE -all_i(VALUE i, VALUE *memo) +all_iter_i(VALUE i, VALUE *memo) { - if (!RTEST(i)) { - *memo = Qfalse; - rb_iter_break(); - } - return Qnil; + return all_i(rb_yield(i), memo); } /* @@ -808,9 +804,9 @@ enum_all(VALUE obj) } static VALUE -any_iter_i(VALUE i, VALUE *memo) +any_i(VALUE i, VALUE *memo) { - if (RTEST(rb_yield(i))) { + if (RTEST(i)) { *memo = Qtrue; rb_iter_break(); } @@ -818,13 +814,9 @@ any_iter_i(VALUE i, VALUE *memo) } static VALUE -any_i(VALUE i, VALUE *memo) +any_iter_i(VALUE i, VALUE *memo) { - if (RTEST(i)) { - *memo = Qtrue; - rb_iter_break(); - } - return Qnil; + return any_i(rb_yield(i), memo); } /* |