diff --git a/ChangeLog b/ChangeLog index 5fdf2d789c..2b5f6b918b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Dec 2 15:30:30 2014 Martin Duerst + + * array.c (rb_ary_plus): in documentation, added note about + inefficiency of repeated += operations. + Tue Dec 2 07:20:21 2014 Eric Wong * iseq.c (iseq_data_to_ary): keep hidden variables diff --git a/array.c b/array.c index 18cde10782..2c390f9749 100644 --- a/array.c +++ b/array.c @@ -3525,9 +3525,17 @@ rb_ary_fill(int argc, VALUE *argv, VALUE ary) * c #=> [ "a", "b", "c", "d", "e", "f" ] * a #=> [ "a", "b", "c" ] * + * Note that + * x += y + * is the same as + * x = x + y + * This means that it produces a new array. As a consequence, + * repeated use of += on arrays can be quite inefficient. + * * See also Array#concat. */ + VALUE rb_ary_plus(VALUE x, VALUE y) {