summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--array.c15
-rw-r--r--test/ruby/test_array.rb16
-rw-r--r--version.h2
4 files changed, 23 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index fb63027b55..a4b5b9992f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed May 28 00:38:37 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * array.c (ary_reject): may be turned into a shared array during
+ the given block. [ruby-dev:48101] [Bug #9727]
+
Wed May 28 00:29:02 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
* string.c (str_buf_cat): should round up the capacity by 4KiB,
diff --git a/array.c b/array.c
index d780f43810..a57733866e 100644
--- a/array.c
+++ b/array.c
@@ -903,19 +903,6 @@ rb_ary_push(VALUE ary, VALUE item)
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_ASET(ary, idx, item);
- ARY_SET_LEN(ary, idx + 1);
- return ary;
-}
-
VALUE
rb_ary_cat(VALUE ary, const VALUE *ptr, long len)
{
@@ -3082,7 +3069,7 @@ ary_reject(VALUE orig, VALUE result)
for (i = 0; i < RARRAY_LEN(orig); i++) {
VALUE v = RARRAY_AREF(orig, i);
if (!RTEST(rb_yield(v))) {
- rb_ary_push_1(result, v);
+ rb_ary_push(result, v);
}
}
return result;
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb
index 3a76889e23..235dda0dca 100644
--- a/test/ruby/test_array.rb
+++ b/test/ruby/test_array.rb
@@ -2011,6 +2011,22 @@ class TestArray < Test::Unit::TestCase
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"]))
diff --git a/version.h b/version.h
index 062e5404e1..6dcc86700a 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.1.2"
#define RUBY_RELEASE_DATE "2014-05-28"
-#define RUBY_PATCHLEVEL 109
+#define RUBY_PATCHLEVEL 110
#define RUBY_RELEASE_YEAR 2014
#define RUBY_RELEASE_MONTH 5