From: Robert Klemme Date: 2009-07-01T20:31:38+09:00 Subject: Re: Making a random string 2009/7/1 Brian Candler : > Robert Klemme wrote: >>>   s.upcase >> >> You can probably squeeze out a bit performance especially for large >> strings by replacing this with "s.upcase!; s". > > A very bad idea IMO. Why make your code larger and less readable for the > sake of perhaps one microsecond or less? I do not subscribe to the "less readable" assessment of yours - uglier, yes. Also note that a microsecond per execution can be harmful when the method is invoked often and / or the rest of the code is not much costlier. > If performance matters on this > microscopic scale, you should be writing in C. I couldn't have put it better than Ellie. Notice that object allocation is one of the most expensive operations in Ruby. So it may pay off to save one. Btw, this is also the reason why my solution only works with Fixnums. Apart from that I find unnecessary object creation ugly. You may call that personal taste but with GC in mind there is also a quantifiable reason to not waste objects. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/