From b4729e2db343077b70ee0cba1565759858a364ba Mon Sep 17 00:00:00 2001 From: yugui Date: Fri, 31 Oct 2008 09:46:31 +0000 Subject: [PATCH] * array.c (ary_partial0): recovers mistakenly feature change at r19723. Array#[m,n] had returned an Array even for an instance of a subclass. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ array.c | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ff9dd73735..7ffa6b60af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Fri Oct 31 18:42:19 2008 Yuki Sonoda (Yugui) + + * array.c (ary_partial0): recovers mistakenly feature change at r19723. + Array#[m,n] had returned an Array even for an instance of a + subclass. + Fri Oct 31 18:05:05 2008 Martin Duerst * enc/trans/single_byte.trans, maccroatioan-tbl.rb, diff --git a/array.c b/array.c index 91bbcf36c1..3556d9393b 100644 --- a/array.c +++ b/array.c @@ -610,7 +610,10 @@ ary_make_partial0(VALUE ary, long offset, long len) assert(offset+len <= RARRAY_LEN(ary)); if (len <= RARRAY_EMBED_LEN_MAX) { - return rb_ary_new4(len, RARRAY_PTR(ary) + offset); + VALUE result = ary_alloc(rb_obj_class(ary)); + MEMCPY(ARY_EMBED_PTR(result), RARRAY_PTR(ary) + offset, VALUE, len); + ARY_SET_EMBED_LEN(result, len); + return result; } else { VALUE shared, result = ary_alloc(rb_obj_class(ary));