From: Gary Weaver Date: 2012-09-26T07:01:08+09:00 Subject: Re: could initialize return an existing object instead of a new instance? Bartosz DziewoƄski wrote in post #1077524: > Is that an academic discussion or an attempt for practical > optimization? Because Ruby sorta kinda does this internally. > > http://patshaughnessy.net/2012/1/4/never-create-ruby-strings-longer-than-23-characters > http://patshaughnessy.net/2012/1/18/seeing-double-how-ruby-shares-string-values Thanks! Wasn't academic. There was a discussion on the rails-core list where someone was complaining about the massive numbers of objects allocated: https://groups.google.com/forum/?fromgroups=#!topic/rubyonrails-core/jFlXnFA4rP8 I just posted those links there. The context was attribute names which primarily were < 23 characters I guess, so didn't benefit from that optimization. I think they merged Jeremy Evans's patch in after much discussion: https://github.com/rails/rails/pull/7631 I was just considering something that could pool all strings, even though it looks like that would slow things down a good bit. Also, I was trying to learn more about it. Mission accomplished! Thanks! -- Posted via http://www.ruby-forum.com/.