From: Robert Dober Date: 2007-08-24T20:29:33+09:00 Subject: Re: something I just found out, am sharing (:newbish) On 8/24/07, David A. Black wrote: > Hi -- > > Don't worry -- there's no Academie Anglaise :-) I am not French, only my wife is;), but it is a funny remark. > > > But seriously there is just no need to pay the cost of the > > construction of another String / Array. > > Performance difference is already enormous for moderately long strings : > > It depends, though; sometimes you might want a copy, sometimes you > might definitely not. So the + vs. << decision may not be premature, > and the right decision may not even be the optimizing one :-) Hmm David when one does a += b the copy is thrown away and you have the same semantics (save some implicit calls to to_s) as for a << b My benchmarks show some dramatic performance degradation already but imagine the GC kicking in because of the temporary copies, no, honestly I feel that beginners should be warned about that idiom. For sure sometimes you want a = b + c but that is a different story. Robert -- I'm an atheist and that's it. I believe there's nothing we can know except that we should be kind to each other and do what we can for other people. -- Katharine Hepburn