ruby-changes:25526
From: nobu <ko1@a...>
Date: Fri, 9 Nov 2012 16:08:56 +0900 (JST)
Subject: [ruby-changes:25526] nobu:r37583 (trunk): array.c: use shared array in rb_ary_slice
nobu 2012-11-09 16:08:45 +0900 (Fri, 09 Nov 2012) New Revision: 37583 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37583 Log: array.c: use shared array in rb_ary_slice * array.c (rb_ary_splice): use shared array in rb_ary_slice. [Feature #6638] - use ary_ensure_room_for_push when rb_ary_slice used to add at the end of array, cause rb_ary_concat use rb_ary_slice. Modified files: trunk/ChangeLog trunk/array.c Index: array.c =================================================================== --- array.c (revision 37582) +++ array.c (revision 37583) @@ -1388,15 +1388,12 @@ rpl = rb_ary_to_ary(rpl); rlen = RARRAY_LEN(rpl); } - rb_ary_modify(ary); if (beg >= RARRAY_LEN(ary)) { if (beg > ARY_MAX_SIZE - rlen) { rb_raise(rb_eIndexError, "index %ld too big", beg); } + ary_ensure_room_for_push(ary, rlen); len = beg + rlen; - if (len >= ARY_CAPA(ary)) { - ary_double_capa(ary, len); - } rb_mem_clear(RARRAY_PTR(ary) + RARRAY_LEN(ary), beg - RARRAY_LEN(ary)); if (rlen > 0) { MEMCPY(RARRAY_PTR(ary) + beg, RARRAY_PTR(rpl), VALUE, rlen); @@ -1406,6 +1403,7 @@ else { long alen; + rb_ary_modify(ary); alen = RARRAY_LEN(ary) + rlen - len; if (alen >= ARY_CAPA(ary)) { ary_double_capa(ary, alen); Index: ChangeLog =================================================================== --- ChangeLog (revision 37582) +++ ChangeLog (revision 37583) @@ -1,5 +1,10 @@ -Fri Nov 9 16:08:39 2012 Sokolov Yura funny-falcon <funny.falcon@g...> +Fri Nov 9 16:08:43 2012 Sokolov Yura funny-falcon <funny.falcon@g...> + * array.c (rb_ary_splice): use shared array in rb_ary_slice. + [Feature #6638] + - use ary_ensure_room_for_push when rb_ary_slice used to add at the + end of array, cause rb_ary_concat use rb_ary_slice. + * array.c (ary_ensure_room_for_push): make array really suitable for queue. [Feature #6638] when array is shared (which happens after Array#shift), and -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/