From: Brian Ford Date: 2008-12-20T15:18:17+09:00 Subject: [ruby-core:20715] Re: [Feature #905] Add String.new(fixnum) to preallocate large buffer On Dec 19, 12:02�am, Martin Duerst wrote: > At 09:08 08/12/19, Brian Ford wrote: > > >Something like "ab" * 5 then becomes String.pattern("ab".size * 5, "ab"). > > I'm at a total loss to see why > � �String.pattern("ab".size * 5, "ab") > should be in any way better than > � �"ab" * 5 > but maybe that's just me. Can somebody explain? It's not better. It's not intended that you see it. Behind the scenes it has been useful for us to have this method. This is one example of its usage. The string is allocated in one step and filled in one loop. There are other places it has been useful. The most useful aspect is requesting a particular size. The initial contents is a lesser, but still useful aspect. The mileage for other implementations may vary. Cheers, Brian > > Regards, � �Martin. > > #-#-# �Martin J. Du"rst, Assoc. Professor, Aoyama Gakuin University > #-#-# �http://www.sw.it.aoyama.ac.jp� � � mailto:due...@it.aoyama.ac.jp � �