ruby-changes:31477
From: glass <ko1@a...>
Date: Wed, 6 Nov 2013 21:09:38 +0900 (JST)
Subject: [ruby-changes:31477] glass:r43556 (trunk): * array.c (rb_ary_reverse): use RARRAY_PTR_USE().
glass 2013-11-06 21:09:31 +0900 (Wed, 06 Nov 2013) New Revision: 43556 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43556 Log: * array.c (rb_ary_reverse): use RARRAY_PTR_USE(). Modified files: trunk/ChangeLog trunk/array.c Index: array.c =================================================================== --- array.c (revision 43555) +++ array.c (revision 43556) @@ -2176,13 +2176,15 @@ ary_reverse(VALUE *p1, VALUE *p2) https://github.com/ruby/ruby/blob/trunk/array.c#L2176 VALUE rb_ary_reverse(VALUE ary) { - VALUE *p1, *p2; + VALUE *p2; + long len = RARRAY_LEN(ary); rb_ary_modify(ary); - if (RARRAY_LEN(ary) > 1) { - p1 = RARRAY_PTR(ary); - p2 = p1 + RARRAY_LEN(ary) - 1; /* points last item */ - ary_reverse(p1, p2); + if (len > 1) { + RARRAY_PTR_USE(ary, p1, { + p2 = p1 + len - 1; /* points last item */ + ary_reverse(p1, p2); + }); /* WB: no new reference */ } return ary; } Index: ChangeLog =================================================================== --- ChangeLog (revision 43555) +++ ChangeLog (revision 43556) @@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Nov 6 21:05:20 2013 Masaki Matsushita <glass.saga@g...> + + * array.c (rb_ary_reverse): use RARRAY_PTR_USE(). + Wed Nov 6 19:30:44 2013 Masaya Tarui <tarui@r...> * common.mk (help): add texts about gcbench. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/