summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-11-27 10:00:35 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-11-27 10:00:35 +0000
commit186c8b592a8b5badfd42ff7295c5edb44ef1abdd (patch)
tree922c6ba9baaf7b140efadfb387c0a0780e544eb6 /array.c
parent09a4937b2fcf883fa57af1dfa5d12f605f812970 (diff)
* marshal.c (w_float): must distinguish -0.0 from 0.0.
* gc.c (gc_mark_all): tweak mark order for little bit better scan. * gc.c (rb_gc_mark): ditto. * gc.c (rb_gc): ditto. * enum.c (sort_by_i): slight performance boost. * gc.c (gc_mark_rest): should call gc_mark_children(), not gc_mark(). * gc.c (rb_gc_mark): may cause infinite looop. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r--array.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/array.c b/array.c
index 9d5dcd7..6a419d8 100644
--- a/array.c
+++ b/array.c
@@ -1087,6 +1087,26 @@ rb_ary_sort(ary)
}
static VALUE
+sort_inplace(ary)
+ VALUE ary;
+{
+ qsort(RARRAY(ary)->ptr, RARRAY(ary)->len, sizeof(VALUE),sort_2);
+ return ary;
+}
+
+VALUE
+rb_ary_sort_inplace(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_inplace, ary, sort_unlock, ary);
+ return ary;
+}
+
+static VALUE
rb_ary_collect(ary)
VALUE ary;
{
@@ -1493,7 +1513,9 @@ rb_ary_cmp(ary, ary2)
{
long i, len;
- ary2 = to_ary(ary2);
+ if (TYPE(ary2) != T_ARRAY) {
+ ary2 = to_ary(ary2);
+ }
len = RARRAY(ary)->len;
if (len > RARRAY(ary2)->len) {
len = RARRAY(ary2)->len;