From: Gary Wright Date: 2008-12-20T15:00:31+09:00 Subject: [ruby-core:20714] Re: [Feature #905] Add String.new(fixnum) to preallocate large buffer On Dec 19, 2008, at 5:28 PM, Charles Oliver Nutter wrote: > I would also expect that the cost of allocating and populating an > arguments hash for this would negate some of the gain from adding > the new form. Array.buffer(100) adds almost no overhead on top of > the physical creation of the backing store and object to wrap it, > where Array.buffer(initial_size: 100) creates both a new Array and a > new Hash. An implementation detail, sure, but we I think we just > need something simple here. Perhaps buffer just doesn't express it > clearly enough? How about: String.reserve(100) Array.reserve(100) String.reserve(100, other_string) Array.reserve(100, start_size, default_object) Array.reserve(100, other_array) Array.reserve(100, start_size) { # default block }