summaryrefslogtreecommitdiffstats
path: root/array.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-09-05 05:07:54 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-09-05 05:07:54 +0000
commitb4d6c1408d23090c5eba02692b9201d82b15aa30 (patch)
treef9703be8248360ab17a94821ad56d785bb27c0a7 /array.c
parent81e98170634bb472059adf761f72954f4c69fd0d (diff)
downloadruby-b4d6c1408d23090c5eba02692b9201d82b15aa30.tar.gz
ruby-b4d6c1408d23090c5eba02692b9201d82b15aa30.tar.xz
ruby-b4d6c1408d23090c5eba02692b9201d82b15aa30.zip
* eval.c (mark_frame_adj): need to adjust argv pointer if using
system's alloca. [ruby-core:01503] * io.c (rb_f_gets): should call next_argv() before type check current_file. [ruby-list:38336] * eval.c (proc_invoke): should retrieve retval when pcall is true. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@4509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r--array.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/array.c b/array.c
index 46b088991..ed562060d 100644
--- a/array.c
+++ b/array.c
@@ -1095,17 +1095,16 @@ rb_ary_reverse(ary)
VALUE tmp;
rb_ary_modify(ary);
- if (RARRAY(ary)->len <= 1) return ary;
-
- p1 = RARRAY(ary)->ptr;
- p2 = p1 + RARRAY(ary)->len - 1; /* points last item */
-
- while (p1 < p2) {
- tmp = *p1;
- *p1++ = *p2;
- *p2-- = tmp;
+ if (RARRAY(ary)->len > 1) {
+ p1 = RARRAY(ary)->ptr;
+ p2 = p1 + RARRAY(ary)->len - 1; /* points last item */
+
+ while (p1 < p2) {
+ tmp = *p1;
+ *p1++ = *p2;
+ *p2-- = tmp;
+ }
}
-
return ary;
}
@@ -1173,10 +1172,10 @@ rb_ary_sort_bang(ary)
VALUE ary;
{
rb_ary_modify(ary);
- if (RARRAY(ary)->len <= 1) return ary;
-
- FL_SET(ary, ARY_TMPLOCK); /* prohibit modification during sort */
- rb_ensure(sort_internal, ary, sort_unlock, ary);
+ if (RARRAY(ary)->len > 1) {
+ FL_SET(ary, ARY_TMPLOCK); /* prohibit modification during sort */
+ rb_ensure(sort_internal, ary, sort_unlock, ary);
+ }
return ary;
}