summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
authorglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-06 12:09:31 +0000
committerglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-06 12:09:31 +0000
commit27f2c267fd667045ed7288d91076508618cfe0a8 (patch)
tree36317b37d1aa1837f7e37a2fe83983d76491ea54 /array.c
parenta50ce9498cf36e93bfd0ede9e97e75414de70996 (diff)
* 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
Diffstat (limited to 'array.c')
-rw-r--r--array.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/array.c b/array.c
index e708cb1..2a85772 100644
--- a/array.c
+++ b/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;
}