{"action":"created","issue":{"url":"https://api.github.com/repos/mikel/mail/issues/955","labels_url":"https://api.github.com/repos/mikel/mail/issues/955/labels{/name}","comments_url":"https://api.github.com/repos/mikel/mail/issues/955/comments","events_url":"https://api.github.com/repos/mikel/mail/issues/955/events","html_url":"https://github.com/mikel/mail/issues/955","id":126727392,"number":955,"title":"Mail::Utilities.to_crlf Improvement","user":{"login":"carsonreinke","id":378481,"avatar_url":"https://avatars.githubusercontent.com/u/378481?v=3","gravatar_id":"","url":"https://api.github.com/users/carsonreinke","html_url":"https://github.com/carsonreinke","followers_url":"https://api.github.com/users/carsonreinke/followers","following_url":"https://api.github.com/users/carsonreinke/following{/other_user}","gists_url":"https://api.github.com/users/carsonreinke/gists{/gist_id}","starred_url":"https://api.github.com/users/carsonreinke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carsonreinke/subscriptions","organizations_url":"https://api.github.com/users/carsonreinke/orgs","repos_url":"https://api.github.com/users/carsonreinke/repos","events_url":"https://api.github.com/users/carsonreinke/events{/privacy}","received_events_url":"https://api.github.com/users/carsonreinke/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-14T19:17:54Z","updated_at":"2016-01-14T19:30:46Z","closed_at":null,"body":"`Mail::Utilities.to_crlf` seems like it can be changed to not use a `Regexp` instead by using `String#encode`.\r\n\r\nRunning this test:\r\n```ruby\r\nrequire 'benchmark'\r\n\r\nCRLF = \"\\r\\n\"\r\nCRLF_REGEX = Regexp.new(\"(?<!\\r)\\n|\\r(?!\\n)\")\r\n\r\nstring = \"\\n\\r\\n\\n\" * 10_000\r\n\r\nBenchmark.bm do |x|\r\n  x.report('to_crlf:') do\r\n    10_000.times do\r\n      string.gsub(CRLF_REGEX, CRLF)\r\n    end\r\n  end\r\n  \r\n  x.report('encode:') do\r\n    10_000.times do\r\n      string.encode(:universal_newline => true).encode!(:crlf_newline => true)\r\n    end\r\n  end\r\nend\r\n```\r\n... I get these results on 2.3.0:\r\n```\r\n       user     system      total        real\r\nto_crlf: 57.450000   0.120000  57.570000 ( 57.580348)\r\nencode:  7.790000   0.090000   7.880000 (  7.889390)\r\n```\r\n\r\nAm I missing something here?  I will put in a PR if not."},"comment":{"url":"https://api.github.com/repos/mikel/mail/issues/comments/171752795","html_url":"https://github.com/mikel/mail/issues/955#issuecomment-171752795","issue_url":"https://api.github.com/repos/mikel/mail/issues/955","id":171752795,"user":{"login":"kjg","id":2205,"avatar_url":"https://avatars.githubusercontent.com/u/2205?v=3","gravatar_id":"","url":"https://api.github.com/users/kjg","html_url":"https://github.com/kjg","followers_url":"https://api.github.com/users/kjg/followers","following_url":"https://api.github.com/users/kjg/following{/other_user}","gists_url":"https://api.github.com/users/kjg/gists{/gist_id}","starred_url":"https://api.github.com/users/kjg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kjg/subscriptions","organizations_url":"https://api.github.com/users/kjg/orgs","repos_url":"https://api.github.com/users/kjg/repos","events_url":"https://api.github.com/users/kjg/events{/privacy}","received_events_url":"https://api.github.com/users/kjg/received_events","type":"User","site_admin":false},"created_at":"2016-01-14T19:30:46Z","updated_at":"2016-01-14T19:30:46Z","body":"I'm not a maintainer or anything, but I say make a PR, include this perf info there. If all the tests still pass in the CI run for the PR, I can't see why they'd turn it down."}}