[前][次][番号順一覧][スレッド一覧]

ruby-changes:4873

From: ko1@a...
Date: Sun, 11 May 2008 23:19:56 +0900 (JST)
Subject: [ruby-changes:4873] nobu - Ruby:r16366 (ruby_1_8, trunk): * enum.c (all_iter_i, any_iter_i): reduced duplicated code.

nobu	2008-05-11 23:19:41 +0900 (Sun, 11 May 2008)

  New Revision: 16366

  Modified files:
    branches/ruby_1_8/ChangeLog
    branches/ruby_1_8/enum.c
    trunk/ChangeLog
    trunk/enum.c

  Log:
    * enum.c (all_iter_i, any_iter_i): reduced duplicated code.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/enum.c?r1=16366&r2=16365&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/ChangeLog?r1=16366&r2=16365&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=16366&r2=16365&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/enum.c?r1=16366&r2=16365&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 16365)
+++ ChangeLog	(revision 16366)
@@ -1,3 +1,7 @@
+Sun May 11 23:19:39 2008  Nobuyoshi Nakada  <nobu@r...>
+
+	* enum.c (all_iter_i, any_iter_i): reduced duplicated code.
+
 Sun May 11 22:54:02 2008  Nobuyoshi Nakada  <nobu@r...>
 
 	* bootstraptest/runner.rb (main): leave -I options for purelib.rb
Index: enum.c
===================================================================
--- enum.c	(revision 16365)
+++ enum.c	(revision 16366)
@@ -762,9 +762,9 @@
 }
 
 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 @@
 }
 
 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 @@
 }
 
 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 @@
 }
 
 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);
 }
 
 /*
Index: ruby_1_8/ChangeLog
===================================================================
--- ruby_1_8/ChangeLog	(revision 16365)
+++ ruby_1_8/ChangeLog	(revision 16366)
@@ -1,3 +1,7 @@
+Sun May 11 23:19:39 2008  Nobuyoshi Nakada  <nobu@r...>
+
+	* enum.c (all_iter_i, any_iter_i): reduced duplicated code.
+
 Sun May 11 17:57:36 2008  Nobuyoshi Nakada  <nobu@r...>
 
 	* configure.in (MINIRUBY): should not include extension library path.
Index: ruby_1_8/enum.c
===================================================================
--- ruby_1_8/enum.c	(revision 16365)
+++ ruby_1_8/enum.c	(revision 16366)
@@ -844,11 +844,11 @@
 }
 
 static VALUE
-all_iter_i(i, memo)
+all_i(i, memo)
     VALUE i;
     VALUE *memo;
 {
-    if (!RTEST(rb_yield(i))) {
+    if (!RTEST(i)) {
 	*memo = Qfalse;
 	rb_iter_break();
     }
@@ -856,15 +856,11 @@
 }
 
 static VALUE
-all_i(i, memo)
+all_iter_i(i, memo)
     VALUE i;
     VALUE *memo;
 {
-    if (!RTEST(i)) {
-	*memo = Qfalse;
-	rb_iter_break();
-    }
-    return Qnil;
+    return all_i(rb_yield(i), memo);
 }
 
 /*
@@ -895,11 +891,11 @@
 }
 
 static VALUE
-any_iter_i(i, memo)
+any_i(i, memo)
     VALUE i;
     VALUE *memo;
 {
-    if (RTEST(rb_yield(i))) {
+    if (RTEST(i)) {
 	*memo = Qtrue;
 	rb_iter_break();
     }
@@ -907,15 +903,11 @@
 }
 
 static VALUE
-any_i(i, memo)
+any_iter_i(i, memo)
     VALUE i;
     VALUE *memo;
 {
-    if (RTEST(i)) {
-	*memo = Qtrue;
-	rb_iter_break();
-    }
-    return Qnil;
+    return any_i(rb_yield(i), memo);
 }
 
 /*

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]