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

ruby-changes:34074

From: usa <ko1@a...>
Date: Tue, 27 May 2014 11:52:58 +0900 (JST)
Subject: [ruby-changes:34074] usa:r46155 (ruby_2_0_0): merge revision(s) 45562: [Backport #9727]

usa	2014-05-27 11:52:49 +0900 (Tue, 27 May 2014)

  New Revision: 46155

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=46155

  Log:
    merge revision(s) 45562: [Backport #9727]
    
    * array.c (ary_reject): may be turned into a shared array during
      the given block.  [ruby-dev:48101] [Bug #9727]

  Modified directories:
    branches/ruby_2_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/array.c
    branches/ruby_2_0_0/test/ruby/test_array.rb
    branches/ruby_2_0_0/version.h
Index: ruby_2_0_0/array.c
===================================================================
--- ruby_2_0_0/array.c	(revision 46154)
+++ ruby_2_0_0/array.c	(revision 46155)
@@ -829,19 +829,6 @@ rb_ary_push(VALUE ary, VALUE item) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/array.c#L829
     return ary;
 }
 
-static VALUE
-rb_ary_push_1(VALUE ary, VALUE item)
-{
-    long idx = RARRAY_LEN(ary);
-
-    if (idx >= ARY_CAPA(ary)) {
-	ary_double_capa(ary, idx);
-    }
-    RARRAY_PTR(ary)[idx] = item;
-    ARY_SET_LEN(ary, idx + 1);
-    return ary;
-}
-
 VALUE
 rb_ary_cat(VALUE ary, const VALUE *ptr, long len)
 {
@@ -2931,7 +2918,7 @@ ary_reject(VALUE orig, VALUE result) https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/array.c#L2918
     for (i = 0; i < RARRAY_LEN(orig); i++) {
 	VALUE v = RARRAY_PTR(orig)[i];
 	if (!RTEST(rb_yield(v))) {
-	    rb_ary_push_1(result, v);
+	    rb_ary_push(result, v);
 	}
     }
     return result;
Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 46154)
+++ ruby_2_0_0/ChangeLog	(revision 46155)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Tue May 27 11:51:00 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* array.c (ary_reject): may be turned into a shared array during
+	  the given block.  [ruby-dev:48101] [Bug #9727]
+
 Tue May 27 11:48:22 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* string.c (str_buf_cat): should round up the capacity by 4KiB,
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 46154)
+++ ruby_2_0_0/version.h	(revision 46155)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
 #define RUBY_RELEASE_DATE "2014-05-27"
-#define RUBY_PATCHLEVEL 484
+#define RUBY_PATCHLEVEL 485
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 5
Index: ruby_2_0_0/test/ruby/test_array.rb
===================================================================
--- ruby_2_0_0/test/ruby/test_array.rb	(revision 46154)
+++ ruby_2_0_0/test/ruby/test_array.rb	(revision 46155)
@@ -1925,6 +1925,22 @@ class TestArray < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_array.rb#L1925
     assert_equal([1, 3], [0, 1, 2, 3].reject {|x| x % 2 == 0 })
   end
 
+  def test_reject_with_callcc
+    respond_to?(:callcc, true) or require 'continuation'
+    bug9727 = '[ruby-dev:48101] [Bug #9727]'
+    cont = nil
+    a = [*1..10].reject do |i|
+      callcc {|c| cont = c} if !cont and i == 10
+      false
+    end
+    if a.size < 1000
+      a.unshift(:x)
+      cont.call
+    end
+    assert_equal(1000, a.size, bug9727)
+    assert_equal([:x, *1..10], a.uniq, bug9727)
+  end
+
   def test_zip
     assert_equal([[1, :a, "a"], [2, :b, "b"], [3, nil, "c"]],
       [1, 2, 3].zip([:a, :b], ["a", "b", "c", "d"]))

Property changes on: ruby_2_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r45562


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

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