From: Yusuke ENDOH Date: 2009-12-02T02:19:33+09:00 Subject: [ruby-core:26978] Re: Caching #to_s for immutables (and a possible future for constant-folding) [with patch v2] Hi, 2009/12/1 Kurt Stephens : > I fixed issues uncovered by running make test-all. There were a few tests > and modules that assumed Symbol#to_s was mutable -- #method_missing appears > to be a hot-bed for this assumption. There were 7 common failures between > the patched code and the svn trunk: > > WITHOUT THE PATCH: > > real 5m19.335s > user 2m15.804s > sys 0m35.850s > > WITH THE PATCH: > > real 4m37.127s > user 1m51.243s > sys 0m33.454s > > Approx 14% faster. This is really interesting result, but the impact of the spec change seems not to be small. I guess that it may be acceptable for Ruby 2.0, but NG for 1.8 and 1.9. How about if #to_s returns, instead of a frozen String itself, a mutable String that is duplicated from the cached frozen String? Become less effective than now? -- Yusuke ENDOH