From: Eric Wong Date: 2013-11-27T07:15:31+00:00 Subject: [ruby-core:58631] Re: [ruby-trunk - Feature #8998] string keys for hash literals should use fstrings "tmm1 (Aman Gupta)" wrote: > Issue #8998 has been updated by tmm1 (Aman Gupta). Cool, I didn't check object lifetimes. Any measurable impact on speed? > >+ if (!OBJ_FROZEN(str)) > >+ *key = rb_fstring(str); > > Do you know why the OBJ_FROZEN check is required here? Some apps use frozen constant strings to speed up hash assignment for common string keys. No point in having the extra hash lookup if it was already a pre-frozen string (and it could break existing behavior). Ideally it would be nice to transparently freeze strings used for hash assignment in the parser so apps wouldn't have to add the ugly frozen constants. Mongrel, and most probably every server descended from Mongrel uses pre-frozen constants to speed up hash assignment. > I tried to investigate and it appears this function is sometimes > invoked with symbols. Really? Yikes! That's strange. I didn't expect that, and I'm not sure how it could be from reading rb_hash_aset()...