From: Michal Rokos Date: 2002-08-23T18:37:41+09:00 Subject: [Optim] Array#select Hi, memory opt version of Array#select. (Easy change, nothing to say more.) Michal Index: array.c =================================================================== RCS file: /src/ruby/array.c,v retrieving revision 1.91 diff -u -r1.91 array.c --- array.c 2002/08/23 07:48:48 1.91 +++ array.c 2002/08/23 09:34:33 @@ -1180,13 +1180,14 @@ VALUE *argv; VALUE ary; { - VALUE result = rb_ary_new(); + VALUE result; long i; if (rb_block_given_p()) { if (argc > 0) { rb_raise(rb_eArgError, "wrong number arguments (%d for 0)", argc); } + result = rb_ary_new2(RARRAY(ary)->len); for (i = 0; i < RARRAY(ary)->len; i++) { if (RTEST(rb_yield(RARRAY(ary)->ptr[i]))) { rb_ary_push(result, RARRAY(ary)->ptr[i]); @@ -1194,6 +1195,7 @@ } } else { + result = rb_ary_new2(argc); for (i=0; i