{"action":"created","issue":{"url":"https://api.github.com/repos/jruby/jruby/issues/2990","labels_url":"https://api.github.com/repos/jruby/jruby/issues/2990/labels{/name}","comments_url":"https://api.github.com/repos/jruby/jruby/issues/2990/comments","events_url":"https://api.github.com/repos/jruby/jruby/issues/2990/events","html_url":"https://github.com/jruby/jruby/issues/2990","id":81102369,"number":2990,"title":"Apply frozen string optimizations as in MRI","user":{"login":"headius","id":10135,"avatar_url":"https://avatars.githubusercontent.com/u/10135?v=3","gravatar_id":"","url":"https://api.github.com/users/headius","html_url":"https://github.com/headius","followers_url":"https://api.github.com/users/headius/followers","following_url":"https://api.github.com/users/headius/following{/other_user}","gists_url":"https://api.github.com/users/headius/gists{/gist_id}","starred_url":"https://api.github.com/users/headius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/headius/subscriptions","organizations_url":"https://api.github.com/users/headius/orgs","repos_url":"https://api.github.com/users/headius/repos","events_url":"https://api.github.com/users/headius/events{/privacy}","received_events_url":"https://api.github.com/users/headius/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-05-26T19:30:00Z","updated_at":"2015-05-26T19:48:58Z","closed_at":null,"body":"We are not doing the frozen string optimization (deduplicating them using a weak internal set) in as many places as MRI. We do it for the literal case of `\"string\".freeze`, and until I remove it (for compat reasons) we attempted to do it for all string keys given to hashes. MRI does it in the following places, based on current MRI trunk:\r\n\r\n* For the pieces of a dstr, since they don't need to be recreated every time (compile_dstr_fragments in MRI).\r\n* Literal strings passed to `when` cases (case_when_optimizable_literal, when_vals in MRI).\r\n* The literal freeze case (`\"string\".freeze`).\r\n* For any calls to [] or []= with a *literal* string that end up in a builtin class that doesn't care if it's frozen (e.g. Hash#[] or String#[], but need to confirm in opt_aref_with and opt_aset_with instrs).\r\n* For the cached string object inside NODE_STR, presumably dup'ed on execution (we already cache ByteList).\r\n* For the string backing a simple xstr (this always was frozen, and I don't believe it checks for Kernel#\\`).\r\n"},"comment":{"url":"https://api.github.com/repos/jruby/jruby/issues/comments/105645846","html_url":"https://github.com/jruby/jruby/issues/2990#issuecomment-105645846","issue_url":"https://api.github.com/repos/jruby/jruby/issues/2990","id":105645846,"user":{"login":"enebo","id":19819,"avatar_url":"https://avatars.githubusercontent.com/u/19819?v=3","gravatar_id":"","url":"https://api.github.com/users/enebo","html_url":"https://github.com/enebo","followers_url":"https://api.github.com/users/enebo/followers","following_url":"https://api.github.com/users/enebo/following{/other_user}","gists_url":"https://api.github.com/users/enebo/gists{/gist_id}","starred_url":"https://api.github.com/users/enebo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/enebo/subscriptions","organizations_url":"https://api.github.com/users/enebo/orgs","repos_url":"https://api.github.com/users/enebo/repos","events_url":"https://api.github.com/users/enebo/events{/privacy}","received_events_url":"https://api.github.com/users/enebo/received_events","type":"User","site_admin":false},"created_at":"2015-05-26T19:48:58Z","updated_at":"2015-05-26T19:48:58Z","body":"Idea for snippet above would be a special call instr (e.g. call_builtin_with_frozen)?  It makes me wonder though if this should just use our instructions.specialized.* and Call.create will do the right thing internally."}}