mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 21:49:06 +02:00
merges r23191 from trunk into ruby_1_9_1.
-- * array.c (rb_ary_flatten): flatten(0) works as Array#dup. [ruby-core:23168] * test/ruby/test_array.rb: add a test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@23339 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
90c2b67432
commit
974d1ae287
3 changed files with 19 additions and 1 deletions
8
array.c
8
array.c
|
@ -630,6 +630,12 @@ ary_make_partial(VALUE ary, VALUE klass, long offset, long len)
|
|||
}
|
||||
}
|
||||
|
||||
static VALUE
|
||||
ary_make_shared_copy(VALUE ary)
|
||||
{
|
||||
return ary_make_partial(ary, rb_obj_class(ary), 0, RARRAY_LEN(ary));
|
||||
}
|
||||
|
||||
enum ary_take_pos_flags
|
||||
{
|
||||
ARY_TAKE_FIRST = 0,
|
||||
|
@ -3219,7 +3225,7 @@ rb_ary_flatten(int argc, VALUE *argv, VALUE ary)
|
|||
|
||||
rb_scan_args(argc, argv, "01", &lv);
|
||||
if (!NIL_P(lv)) level = NUM2INT(lv);
|
||||
if (level == 0) return ary;
|
||||
if (level == 0) return ary_make_shared_copy(ary);
|
||||
|
||||
result = flatten(ary, level, &mod);
|
||||
OBJ_INFECT(result, ary);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue