From 24f5f816ff03621897a4c8b18393d3d027d1f02a Mon Sep 17 00:00:00 2001 From: duerst Date: Tue, 2 Dec 2014 06:30:05 +0000 Subject: array.c (rb_ary_plus): in documentation, added note about inefficiency of repeated += operations. [ci skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ array.c | 8 ++++++++ 2 files changed, 13 insertions(+) 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) { -- cgit v1.2.3