{"action":"created","comment":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/comments/229658193","pull_request_review_id":170206290,"id":229658193,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyOTY1ODE5Mw==","diff_hunk":"@@ -618,7 +618,15 @@ impl String {\n     /// ```\n     #[stable(feature = \"rust1\", since = \"1.0.0\")]\n     pub fn from_utf16(v: &[u16]) -> Result<String, FromUtf16Error> {\n-        decode_utf16(v.iter().cloned()).collect::<Result<_, _>>().map_err(|_| FromUtf16Error(()))\n+        let mut ret = String::with_capacity(v.len());","path":"src/liballoc/string.rs","position":5,"original_position":5,"commit_id":"19aa10132cc727c8561730ab096b21d14507c81d","original_commit_id":"19aa10132cc727c8561730ab096b21d14507c81d","user":{"login":"ljedrz","id":3750347,"node_id":"MDQ6VXNlcjM3NTAzNDc=","avatar_url":"https://avatars3.githubusercontent.com/u/3750347?v=4","gravatar_id":"","url":"https://api.github.com/users/ljedrz","html_url":"https://github.com/ljedrz","followers_url":"https://api.github.com/users/ljedrz/followers","following_url":"https://api.github.com/users/ljedrz/following{/other_user}","gists_url":"https://api.github.com/users/ljedrz/gists{/gist_id}","starred_url":"https://api.github.com/users/ljedrz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ljedrz/subscriptions","organizations_url":"https://api.github.com/users/ljedrz/orgs","repos_url":"https://api.github.com/users/ljedrz/repos","events_url":"https://api.github.com/users/ljedrz/events{/privacy}","received_events_url":"https://api.github.com/users/ljedrz/received_events","type":"User","site_admin":false},"body":"Hmm, but when I modify my test cases to only use less than 50% code units above `0x0800`, the version with floating point arithmetic is actually quite faster ^^. I'll compile a list of results for comparison.","created_at":"2018-10-31T11:36:11Z","updated_at":"2018-10-31T11:36:11Z","html_url":"https://github.com/rust-lang/rust/pull/55530#discussion_r229658193","pull_request_url":"https://api.github.com/repos/rust-lang/rust/pulls/55530","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/comments/229658193"},"html":{"href":"https://github.com/rust-lang/rust/pull/55530#discussion_r229658193"},"pull_request":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/55530"}},"in_reply_to_id":229627819},"pull_request":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/55530","id":227213841,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI3MjEzODQx","html_url":"https://github.com/rust-lang/rust/pull/55530","diff_url":"https://github.com/rust-lang/rust/pull/55530.diff","patch_url":"https://github.com/rust-lang/rust/pull/55530.patch","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/55530","number":55530,"state":"open","locked":false,"title":"Speed up String::from_utf16","user":{"login":"ljedrz","id":3750347,"node_id":"MDQ6VXNlcjM3NTAzNDc=","avatar_url":"https://avatars3.githubusercontent.com/u/3750347?v=4","gravatar_id":"","url":"https://api.github.com/users/ljedrz","html_url":"https://github.com/ljedrz","followers_url":"https://api.github.com/users/ljedrz/followers","following_url":"https://api.github.com/users/ljedrz/following{/other_user}","gists_url":"https://api.github.com/users/ljedrz/gists{/gist_id}","starred_url":"https://api.github.com/users/ljedrz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ljedrz/subscriptions","organizations_url":"https://api.github.com/users/ljedrz/orgs","repos_url":"https://api.github.com/users/ljedrz/repos","events_url":"https://api.github.com/users/ljedrz/events{/privacy}","received_events_url":"https://api.github.com/users/ljedrz/received_events","type":"User","site_admin":false},"body":"Collecting into a `Result` is idiomatic, but not necessarily fast due to rustc not being able to preallocate the right size for the resulting collection. This is fine in case of an error, but IMO we should optimize for the common case, i.e. a successful conversion.\r\n\r\nThis changes the behavior of `String::from_utf16` from collecting into a `Result` to pushing to a preallocated `String` in a loop.\r\n\r\nAccording to [my simple benchmark](https://gist.github.com/ljedrz/953a3fb74058806519bd4d640d6f65ae) this change makes `String::from_utf16` around **twice** as fast.","created_at":"2018-10-31T09:31:27Z","updated_at":"2018-10-31T11:36:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9d64fc9630497b2a47ee3c5ec0a44253079954f9","assignee":{"login":"aidanhs","id":1050652,"node_id":"MDQ6VXNlcjEwNTA2NTI=","avatar_url":"https://avatars1.githubusercontent.com/u/1050652?v=4","gravatar_id":"","url":"https://api.github.com/users/aidanhs","html_url":"https://github.com/aidanhs","followers_url":"https://api.github.com/users/aidanhs/followers","following_url":"https://api.github.com/users/aidanhs/following{/other_user}","gists_url":"https://api.github.com/users/aidanhs/gists{/gist_id}","starred_url":"https://api.github.com/users/aidanhs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aidanhs/subscriptions","organizations_url":"https://api.github.com/users/aidanhs/orgs","repos_url":"https://api.github.com/users/aidanhs/repos","events_url":"https://api.github.com/users/aidanhs/events{/privacy}","received_events_url":"https://api.github.com/users/aidanhs/received_events","type":"User","site_admin":false},"assignees":[{"login":"aidanhs","id":1050652,"node_id":"MDQ6VXNlcjEwNTA2NTI=","avatar_url":"https://avatars1.githubusercontent.com/u/1050652?v=4","gravatar_id":"","url":"https://api.github.com/users/aidanhs","html_url":"https://github.com/aidanhs","followers_url":"https://api.github.com/users/aidanhs/followers","following_url":"https://api.github.com/users/aidanhs/following{/other_user}","gists_url":"https://api.github.com/users/aidanhs/gists{/gist_id}","starred_url":"https://api.github.com/users/aidanhs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aidanhs/subscriptions","organizations_url":"https://api.github.com/users/aidanhs/orgs","repos_url":"https://api.github.com/users/aidanhs/repos","events_url":"https://api.github.com/users/aidanhs/events{/privacy}","received_events_url":"https://api.github.com/users/aidanhs/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":583426710,"node_id":"MDU6TGFiZWw1ODM0MjY3MTA=","url":"https://api.github.com/repos/rust-lang/rust/labels/S-waiting-on-review","name":"S-waiting-on-review","color":"d3dddd","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/rust-lang/rust/pulls/55530/commits","review_comments_url":"https://api.github.com/repos/rust-lang/rust/pulls/55530/comments","review_comment_url":"https://api.github.com/repos/rust-lang/rust/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/55530/comments","statuses_url":"https://api.github.com/repos/rust-lang/rust/statuses/19aa10132cc727c8561730ab096b21d14507c81d","head":{"label":"ljedrz:speed_up_String_from_utf16","ref":"speed_up_String_from_utf16","sha":"19aa10132cc727c8561730ab096b21d14507c81d","user":{"login":"ljedrz","id":3750347,"node_id":"MDQ6VXNlcjM3NTAzNDc=","avatar_url":"https://avatars3.githubusercontent.com/u/3750347?v=4","gravatar_id":"","url":"https://api.github.com/users/ljedrz","html_url":"https://github.com/ljedrz","followers_url":"https://api.github.com/users/ljedrz/followers","following_url":"https://api.github.com/users/ljedrz/following{/other_user}","gists_url":"https://api.github.com/users/ljedrz/gists{/gist_id}","starred_url":"https://api.github.com/users/ljedrz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ljedrz/subscriptions","organizations_url":"https://api.github.com/users/ljedrz/orgs","repos_url":"https://api.github.com/users/ljedrz/repos","events_url":"https://api.github.com/users/ljedrz/events{/privacy}","received_events_url":"https://api.github.com/users/ljedrz/received_events","type":"User","site_admin":false},"repo":{"id":138298132,"node_id":"MDEwOlJlcG9zaXRvcnkxMzgyOTgxMzI=","name":"rust-1","full_name":"ljedrz/rust-1","private":false,"owner":{"login":"ljedrz","id":3750347,"node_id":"MDQ6VXNlcjM3NTAzNDc=","avatar_url":"https://avatars3.githubusercontent.com/u/3750347?v=4","gravatar_id":"","url":"https://api.github.com/users/ljedrz","html_url":"https://github.com/ljedrz","followers_url":"https://api.github.com/users/ljedrz/followers","following_url":"https://api.github.com/users/ljedrz/following{/other_user}","gists_url":"https://api.github.com/users/ljedrz/gists{/gist_id}","starred_url":"https://api.github.com/users/ljedrz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ljedrz/subscriptions","organizations_url":"https://api.github.com/users/ljedrz/orgs","repos_url":"https://api.github.com/users/ljedrz/repos","events_url":"https://api.github.com/users/ljedrz/events{/privacy}","received_events_url":"https://api.github.com/users/ljedrz/received_events","type":"User","site_admin":false},"html_url":"https://github.com/ljedrz/rust-1","description":"A safe, concurrent, practical language.","fork":true,"url":"https://api.github.com/repos/ljedrz/rust-1","forks_url":"https://api.github.com/repos/ljedrz/rust-1/forks","keys_url":"https://api.github.com/repos/ljedrz/rust-1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ljedrz/rust-1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ljedrz/rust-1/teams","hooks_url":"https://api.github.com/repos/ljedrz/rust-1/hooks","issue_events_url":"https://api.github.com/repos/ljedrz/rust-1/issues/events{/number}","events_url":"https://api.github.com/repos/ljedrz/rust-1/events","assignees_url":"https://api.github.com/repos/ljedrz/rust-1/assignees{/user}","branches_url":"https://api.github.com/repos/ljedrz/rust-1/branches{/branch}","tags_url":"https://api.github.com/repos/ljedrz/rust-1/tags","blobs_url":"https://api.github.com/repos/ljedrz/rust-1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ljedrz/rust-1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ljedrz/rust-1/git/refs{/sha}","trees_url":"https://api.github.com/repos/ljedrz/rust-1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ljedrz/rust-1/statuses/{sha}","languages_url":"https://api.github.com/repos/ljedrz/rust-1/languages","stargazers_url":"https://api.github.com/repos/ljedrz/rust-1/stargazers","contributors_url":"https://api.github.com/repos/ljedrz/rust-1/contributors","subscribers_url":"https://api.github.com/repos/ljedrz/rust-1/subscribers","subscription_url":"https://api.github.com/repos/ljedrz/rust-1/subscription","commits_url":"https://api.github.com/repos/ljedrz/rust-1/commits{/sha}","git_commits_url":"https://api.github.com/repos/ljedrz/rust-1/git/commits{/sha}","comments_url":"https://api.github.com/repos/ljedrz/rust-1/comments{/number}","issue_comment_url":"https://api.github.com/repos/ljedrz/rust-1/issues/comments{/number}","contents_url":"https://api.github.com/repos/ljedrz/rust-1/contents/{+path}","compare_url":"https://api.github.com/repos/ljedrz/rust-1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ljedrz/rust-1/merges","archive_url":"https://api.github.com/repos/ljedrz/rust-1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ljedrz/rust-1/downloads","issues_url":"https://api.github.com/repos/ljedrz/rust-1/issues{/number}","pulls_url":"https://api.github.com/repos/ljedrz/rust-1/pulls{/number}","milestones_url":"https://api.github.com/repos/ljedrz/rust-1/milestones{/number}","notifications_url":"https://api.github.com/repos/ljedrz/rust-1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ljedrz/rust-1/labels{/name}","releases_url":"https://api.github.com/repos/ljedrz/rust-1/releases{/id}","deployments_url":"https://api.github.com/repos/ljedrz/rust-1/deployments","created_at":"2018-06-22T12:05:10Z","updated_at":"2018-07-13T09:38:34Z","pushed_at":"2018-10-31T09:25:38Z","git_url":"git://github.com/ljedrz/rust-1.git","ssh_url":"git@github.com:ljedrz/rust-1.git","clone_url":"https://github.com/ljedrz/rust-1.git","svn_url":"https://github.com/ljedrz/rust-1","homepage":"https://www.rust-lang.org","size":400265,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rust-lang:master","ref":"master","sha":"05812fa8c588473f03e3fa7cf59cd84f4f37c715","user":{"login":"rust-lang","id":5430905,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU0MzA5MDU=","avatar_url":"https://avatars1.githubusercontent.com/u/5430905?v=4","gravatar_id":"","url":"https://api.github.com/users/rust-lang","html_url":"https://github.com/rust-lang","followers_url":"https://api.github.com/users/rust-lang/followers","following_url":"https://api.github.com/users/rust-lang/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang/subscriptions","organizations_url":"https://api.github.com/users/rust-lang/orgs","repos_url":"https://api.github.com/users/rust-lang/repos","events_url":"https://api.github.com/users/rust-lang/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":724712,"node_id":"MDEwOlJlcG9zaXRvcnk3MjQ3MTI=","name":"rust","full_name":"rust-lang/rust","private":false,"owner":{"login":"rust-lang","id":5430905,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU0MzA5MDU=","avatar_url":"https://avatars1.githubusercontent.com/u/5430905?v=4","gravatar_id":"","url":"https://api.github.com/users/rust-lang","html_url":"https://github.com/rust-lang","followers_url":"https://api.github.com/users/rust-lang/followers","following_url":"https://api.github.com/users/rust-lang/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang/subscriptions","organizations_url":"https://api.github.com/users/rust-lang/orgs","repos_url":"https://api.github.com/users/rust-lang/repos","events_url":"https://api.github.com/users/rust-lang/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/rust-lang/rust","description":"A safe, concurrent, practical language.","fork":false,"url":"https://api.github.com/repos/rust-lang/rust","forks_url":"https://api.github.com/repos/rust-lang/rust/forks","keys_url":"https://api.github.com/repos/rust-lang/rust/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rust-lang/rust/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rust-lang/rust/teams","hooks_url":"https://api.github.com/repos/rust-lang/rust/hooks","issue_events_url":"https://api.github.com/repos/rust-lang/rust/issues/events{/number}","events_url":"https://api.github.com/repos/rust-lang/rust/events","assignees_url":"https://api.github.com/repos/rust-lang/rust/assignees{/user}","branches_url":"https://api.github.com/repos/rust-lang/rust/branches{/branch}","tags_url":"https://api.github.com/repos/rust-lang/rust/tags","blobs_url":"https://api.github.com/repos/rust-lang/rust/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rust-lang/rust/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rust-lang/rust/git/refs{/sha}","trees_url":"https://api.github.com/repos/rust-lang/rust/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rust-lang/rust/statuses/{sha}","languages_url":"https://api.github.com/repos/rust-lang/rust/languages","stargazers_url":"https://api.github.com/repos/rust-lang/rust/stargazers","contributors_url":"https://api.github.com/repos/rust-lang/rust/contributors","subscribers_url":"https://api.github.com/repos/rust-lang/rust/subscribers","subscription_url":"https://api.github.com/repos/rust-lang/rust/subscription","commits_url":"https://api.github.com/repos/rust-lang/rust/commits{/sha}","git_commits_url":"https://api.github.com/repos/rust-lang/rust/git/commits{/sha}","comments_url":"https://api.github.com/repos/rust-lang/rust/comments{/number}","issue_comment_url":"https://api.github.com/repos/rust-lang/rust/issues/comments{/number}","contents_url":"https://api.github.com/repos/rust-lang/rust/contents/{+path}","compare_url":"https://api.github.com/repos/rust-lang/rust/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rust-lang/rust/merges","archive_url":"https://api.github.com/repos/rust-lang/rust/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rust-lang/rust/downloads","issues_url":"https://api.github.com/repos/rust-lang/rust/issues{/number}","pulls_url":"https://api.github.com/repos/rust-lang/rust/pulls{/number}","milestones_url":"https://api.github.com/repos/rust-lang/rust/milestones{/number}","notifications_url":"https://api.github.com/repos/rust-lang/rust/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rust-lang/rust/labels{/name}","releases_url":"https://api.github.com/repos/rust-lang/rust/releases{/id}","deployments_url":"https://api.github.com/repos/rust-lang/rust/deployments","created_at":"2010-06-16T20:39:03Z","updated_at":"2018-10-31T11:26:27Z","pushed_at":"2018-10-31T11:19:52Z","git_url":"git://github.com/rust-lang/rust.git","ssh_url":"git@github.com:rust-lang/rust.git","clone_url":"https://github.com/rust-lang/rust.git","svn_url":"https://github.com/rust-lang/rust","homepage":"https://www.rust-lang.org","size":400992,"stargazers_count":31440,"watchers_count":31440,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5258,"mirror_url":null,"archived":false,"open_issues_count":4470,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":5258,"open_issues":4470,"watchers":31440,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/55530"},"html":{"href":"https://github.com/rust-lang/rust/pull/55530"},"issue":{"href":"https://api.github.com/repos/rust-lang/rust/issues/55530"},"comments":{"href":"https://api.github.com/repos/rust-lang/rust/issues/55530/comments"},"review_comments":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/55530/comments"},"review_comment":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/55530/commits"},"statuses":{"href":"https://api.github.com/repos/rust-lang/rust/statuses/19aa10132cc727c8561730ab096b21d14507c81d"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"ljedrz"}}