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 | |
| 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
| -rw-r--r-- | ChangeLog | 4 | ||||
| -rw-r--r-- | enum.c | 24 |
2 files changed, 12 insertions, 16 deletions
@@ -1,3 +1,7 @@ +Sun May 11 23:19:39 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * enum.c (all_iter_i, any_iter_i): reduced duplicated code. + Sun May 11 22:54:02 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> * bootstraptest/runner.rb (main): leave -I options for purelib.rb @@ -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); } /* |
