From: KOSAKI Motohiro Date: 2016-01-27T08:22:34-05:00 Subject: [ruby-core:73534] Re: [Ruby trunk - Feature #12024] Add String.buffer, for creating strings with large capacities On Tue, Jan 26, 2016 at 7:12 PM, wrote: > Issue #12024 has been updated by Jeremy Evans. > > > I wasn't aware of #905 when I created this, I probably should have searched first. > > This feature is similar to #905, but the implementation is different. The implementation in #905 is an instance method that changes the capacity of an existing string. This is a class method that creates a new string with the given capacity. This does use the method name recommended by matz in #905, by accident, but I'm guessing that makes it a good name. Class method is really bad idea because of thread unsafe. bad scenario example: Thread-A Thread-B ------------------------------------------------- String.buffer(10000) s1 = String.new s2 = String.new String.buffer(10) In above scenario, s2 accidentally get 10000 capability. This is huge memory waste. And as mame said, we already talk about this feature doesn't improve performance in #905. -1. Unsubscribe: