зеркало из https://github.com/github/ruby.git
* array.c (rb_ary_reverse): use RARRAY_PTR_USE().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43556 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
a50ce9498c
Коммит
27f2c267fd
|
@ -1,3 +1,7 @@
|
|||
Wed Nov 6 21:05:20 2013 Masaki Matsushita <glass.saga@gmail.com>
|
||||
|
||||
* array.c (rb_ary_reverse): use RARRAY_PTR_USE().
|
||||
|
||||
Wed Nov 6 19:30:44 2013 Masaya Tarui <tarui@ruby-lang.org>
|
||||
|
||||
* common.mk (help): add texts about gcbench.
|
||||
|
|
12
array.c
12
array.c
|
@ -2176,13 +2176,15 @@ ary_reverse(VALUE *p1, VALUE *p2)
|
|||
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;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче