{"action":"created","issue":{"url":"https://api.github.com/repos/ruby/ruby/issues/333","repository_url":"https://api.github.com/repos/ruby/ruby","labels_url":"https://api.github.com/repos/ruby/ruby/issues/333/labels{/name}","comments_url":"https://api.github.com/repos/ruby/ruby/issues/333/comments","events_url":"https://api.github.com/repos/ruby/ruby/issues/333/events","html_url":"https://github.com/ruby/ruby/pull/333","id":15722009,"number":333,"title":"Performance change: should only attempt unescaping if escape character may be present","user":{"login":"bbxiao1","id":1709841,"avatar_url":"https://avatars.githubusercontent.com/u/1709841?v=3","gravatar_id":"","url":"https://api.github.com/users/bbxiao1","html_url":"https://github.com/bbxiao1","followers_url":"https://api.github.com/users/bbxiao1/followers","following_url":"https://api.github.com/users/bbxiao1/following{/other_user}","gists_url":"https://api.github.com/users/bbxiao1/gists{/gist_id}","starred_url":"https://api.github.com/users/bbxiao1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bbxiao1/subscriptions","organizations_url":"https://api.github.com/users/bbxiao1/orgs","repos_url":"https://api.github.com/users/bbxiao1/repos","events_url":"https://api.github.com/users/bbxiao1/events{/privacy}","received_events_url":"https://api.github.com/users/bbxiao1/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2013-06-19T01:04:36Z","updated_at":"2016-02-04T12:04:30Z","closed_at":"2013-06-25T12:05:46Z","pull_request":{"url":"https://api.github.com/repos/ruby/ruby/pulls/333","html_url":"https://github.com/ruby/ruby/pull/333","diff_url":"https://github.com/ruby/ruby/pull/333.diff","patch_url":"https://github.com/ruby/ruby/pull/333.patch"},"body":"Encoding changes from 1.8 to 1.9 has made calls to CGI::unescapeHTML more expensive, even if no escaping needs to be done. While a few calls will have negligible difference, unescaping each line of a large CSV file will cause the losses to stack up.\r\n\r\nBenchmarking\r\n```ruby\r\nrequire 'cgi'\r\nrequire 'benchmark'\r\n\r\nBenchmark.bm(5) do |x|\r\n  puts RUBY_VERSION\r\n  string = CGI.escapeHTML(\"A\") # => \"A\"\r\n\tx.report(\"CGI::unescapeHTML\") do\r\n    100_000.times do\r\n      CGI.unescapeHTML(string)\r\n    end\r\n  end\r\nend\r\n```\r\n\r\n1.8.7-p371\r\n\r\n    user     system      total        real\r\n    CGI::unescapeHTML  0.040000   0.000000   0.040000 (  0.041975)\r\n\r\n1.9.3-p429 (with railsexpress patches and GC tuning)\r\n\r\n    RUBY_GC_MALLOC_LIMIT=1000000000\r\n    RUBY_FREE_MIN=500000\r\n    RUBY_HEAP_MIN_SLOTS=40000\r\n\r\n    user     system      total        real\r\n    CGI::unescapeHTML  0.120000   0.010000   0.130000 (  0.127006)\r\n\r\n    user     system      total        real\r\n    CGI::unescapeHTML with performance change  0.060000   0.000000   0.060000 (  0.058035)"},"comment":{"url":"https://api.github.com/repos/ruby/ruby/issues/comments/179791068","html_url":"https://github.com/ruby/ruby/pull/333#issuecomment-179791068","issue_url":"https://api.github.com/repos/ruby/ruby/issues/333","id":179791068,"user":{"login":"nobu","id":16700,"avatar_url":"https://avatars.githubusercontent.com/u/16700?v=3","gravatar_id":"","url":"https://api.github.com/users/nobu","html_url":"https://github.com/nobu","followers_url":"https://api.github.com/users/nobu/followers","following_url":"https://api.github.com/users/nobu/following{/other_user}","gists_url":"https://api.github.com/users/nobu/gists{/gist_id}","starred_url":"https://api.github.com/users/nobu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nobu/subscriptions","organizations_url":"https://api.github.com/users/nobu/orgs","repos_url":"https://api.github.com/users/nobu/repos","events_url":"https://api.github.com/users/nobu/events{/privacy}","received_events_url":"https://api.github.com/users/nobu/received_events","type":"User","site_admin":false},"created_at":"2016-02-04T12:04:30Z","updated_at":"2016-02-04T12:04:30Z","body":"HTML data can be any valid encodings.\r\nSo this is just a bug."}}