{"action":"created","comment":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/comments/32581350","id":32581350,"diff_hunk":"@@ -1484,11 +1468,27 @@ impl<'a, T> IntoIterator for &'a mut Vec<T> {\n impl<T> Extend<T> for Vec<T> {\n     #[inline]\n     fn extend<I: IntoIterator<Item=T>>(&mut self, iterable: I) {\n-        let iterator = iterable.into_iter();\n-        let (lower, _) = iterator.size_hint();\n-        self.reserve(lower);\n-        for element in iterator {\n-            self.push(element)\n+        self.extend_desugared(iterable.into_iter())\n+    }\n+}\n+\n+impl<T> Vec<T> {\n+    fn extend_desugared<I: Iterator<Item=T>>(&mut self, mut iterator: I) {\n+        // This function should be the moral equivalent of:\n+        //\n+        //      for item in iterator {\n+        //          self.push(item);\n+        //      }\n+        while let Some(element) = iterator.next() {\n+            let len = self.len();\n+            if len == self.capacity() {\n+                let (lower, _) = iterator.size_hint();","path":"src/libcollections/vec.rs","position":84,"original_position":84,"commit_id":"7b464d364b33915b88f67213a3329e0a3d997e4d","original_commit_id":"7b464d364b33915b88f67213a3329e0a3d997e4d","user":{"login":"Gankro","id":1136864,"avatar_url":"https://avatars.githubusercontent.com/u/1136864?v=3","gravatar_id":"","url":"https://api.github.com/users/Gankro","html_url":"https://github.com/Gankro","followers_url":"https://api.github.com/users/Gankro/followers","following_url":"https://api.github.com/users/Gankro/following{/other_user}","gists_url":"https://api.github.com/users/Gankro/gists{/gist_id}","starred_url":"https://api.github.com/users/Gankro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gankro/subscriptions","organizations_url":"https://api.github.com/users/Gankro/orgs","repos_url":"https://api.github.com/users/Gankro/repos","events_url":"https://api.github.com/users/Gankro/events{/privacy}","received_events_url":"https://api.github.com/users/Gankro/received_events","type":"User","site_admin":false},"body":"Oh derp, sure.","created_at":"2015-06-16T23:07:47Z","updated_at":"2015-06-16T23:07:47Z","html_url":"https://github.com/rust-lang/rust/pull/22681#discussion_r32581350","pull_request_url":"https://api.github.com/repos/rust-lang/rust/pulls/22681","_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/comments/32581350"},"html":{"href":"https://github.com/rust-lang/rust/pull/22681#discussion_r32581350"},"pull_request":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/22681"}}},"pull_request":{"url":"https://api.github.com/repos/rust-lang/rust/pulls/22681","id":29774808,"html_url":"https://github.com/rust-lang/rust/pull/22681","diff_url":"https://github.com/rust-lang/rust/pull/22681.diff","patch_url":"https://github.com/rust-lang/rust/pull/22681.patch","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/22681","number":22681,"state":"open","locked":false,"title":"Optimize implementations of FromIterator and Extend for Vec","user":{"login":"mzabaluev","id":1198919,"avatar_url":"https://avatars.githubusercontent.com/u/1198919?v=3","gravatar_id":"","url":"https://api.github.com/users/mzabaluev","html_url":"https://github.com/mzabaluev","followers_url":"https://api.github.com/users/mzabaluev/followers","following_url":"https://api.github.com/users/mzabaluev/following{/other_user}","gists_url":"https://api.github.com/users/mzabaluev/gists{/gist_id}","starred_url":"https://api.github.com/users/mzabaluev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mzabaluev/subscriptions","organizations_url":"https://api.github.com/users/mzabaluev/orgs","repos_url":"https://api.github.com/users/mzabaluev/repos","events_url":"https://api.github.com/users/mzabaluev/events{/privacy}","received_events_url":"https://api.github.com/users/mzabaluev/received_events","type":"User","site_admin":false},"body":"Instead of a fast branch with a sized iterator falling back to a potentially poorly optimized iterate-and-push loop, a single efficient loop can serve all cases.\r\n\r\nIn my benchmark runs, I see some good gains, but also some regressions, possibly due to different inlining choices by the compiler. YMMV.","created_at":"2015-02-22T18:58:59Z","updated_at":"2015-06-16T23:07:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a6620f01f33cf8b93c1ed6c03634de1e8a7dff0a","assignee":{"login":"huonw","id":1203825,"avatar_url":"https://avatars.githubusercontent.com/u/1203825?v=3","gravatar_id":"","url":"https://api.github.com/users/huonw","html_url":"https://github.com/huonw","followers_url":"https://api.github.com/users/huonw/followers","following_url":"https://api.github.com/users/huonw/following{/other_user}","gists_url":"https://api.github.com/users/huonw/gists{/gist_id}","starred_url":"https://api.github.com/users/huonw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/huonw/subscriptions","organizations_url":"https://api.github.com/users/huonw/orgs","repos_url":"https://api.github.com/users/huonw/repos","events_url":"https://api.github.com/users/huonw/events{/privacy}","received_events_url":"https://api.github.com/users/huonw/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/rust-lang/rust/pulls/22681/commits","review_comments_url":"https://api.github.com/repos/rust-lang/rust/pulls/22681/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/22681/comments","statuses_url":"https://api.github.com/repos/rust-lang/rust/statuses/7b464d364b33915b88f67213a3329e0a3d997e4d","head":{"label":"mzabaluev:extend-faster","ref":"extend-faster","sha":"7b464d364b33915b88f67213a3329e0a3d997e4d","user":{"login":"mzabaluev","id":1198919,"avatar_url":"https://avatars.githubusercontent.com/u/1198919?v=3","gravatar_id":"","url":"https://api.github.com/users/mzabaluev","html_url":"https://github.com/mzabaluev","followers_url":"https://api.github.com/users/mzabaluev/followers","following_url":"https://api.github.com/users/mzabaluev/following{/other_user}","gists_url":"https://api.github.com/users/mzabaluev/gists{/gist_id}","starred_url":"https://api.github.com/users/mzabaluev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mzabaluev/subscriptions","organizations_url":"https://api.github.com/users/mzabaluev/orgs","repos_url":"https://api.github.com/users/mzabaluev/repos","events_url":"https://api.github.com/users/mzabaluev/events{/privacy}","received_events_url":"https://api.github.com/users/mzabaluev/received_events","type":"User","site_admin":false},"repo":{"id":30235373,"name":"rust","full_name":"mzabaluev/rust","owner":{"login":"mzabaluev","id":1198919,"avatar_url":"https://avatars.githubusercontent.com/u/1198919?v=3","gravatar_id":"","url":"https://api.github.com/users/mzabaluev","html_url":"https://github.com/mzabaluev","followers_url":"https://api.github.com/users/mzabaluev/followers","following_url":"https://api.github.com/users/mzabaluev/following{/other_user}","gists_url":"https://api.github.com/users/mzabaluev/gists{/gist_id}","starred_url":"https://api.github.com/users/mzabaluev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mzabaluev/subscriptions","organizations_url":"https://api.github.com/users/mzabaluev/orgs","repos_url":"https://api.github.com/users/mzabaluev/repos","events_url":"https://api.github.com/users/mzabaluev/events{/privacy}","received_events_url":"https://api.github.com/users/mzabaluev/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mzabaluev/rust","description":"a safe, concurrent, practical language","fork":true,"url":"https://api.github.com/repos/mzabaluev/rust","forks_url":"https://api.github.com/repos/mzabaluev/rust/forks","keys_url":"https://api.github.com/repos/mzabaluev/rust/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mzabaluev/rust/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mzabaluev/rust/teams","hooks_url":"https://api.github.com/repos/mzabaluev/rust/hooks","issue_events_url":"https://api.github.com/repos/mzabaluev/rust/issues/events{/number}","events_url":"https://api.github.com/repos/mzabaluev/rust/events","assignees_url":"https://api.github.com/repos/mzabaluev/rust/assignees{/user}","branches_url":"https://api.github.com/repos/mzabaluev/rust/branches{/branch}","tags_url":"https://api.github.com/repos/mzabaluev/rust/tags","blobs_url":"https://api.github.com/repos/mzabaluev/rust/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mzabaluev/rust/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mzabaluev/rust/git/refs{/sha}","trees_url":"https://api.github.com/repos/mzabaluev/rust/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mzabaluev/rust/statuses/{sha}","languages_url":"https://api.github.com/repos/mzabaluev/rust/languages","stargazers_url":"https://api.github.com/repos/mzabaluev/rust/stargazers","contributors_url":"https://api.github.com/repos/mzabaluev/rust/contributors","subscribers_url":"https://api.github.com/repos/mzabaluev/rust/subscribers","subscription_url":"https://api.github.com/repos/mzabaluev/rust/subscription","commits_url":"https://api.github.com/repos/mzabaluev/rust/commits{/sha}","git_commits_url":"https://api.github.com/repos/mzabaluev/rust/git/commits{/sha}","comments_url":"https://api.github.com/repos/mzabaluev/rust/comments{/number}","issue_comment_url":"https://api.github.com/repos/mzabaluev/rust/issues/comments{/number}","contents_url":"https://api.github.com/repos/mzabaluev/rust/contents/{+path}","compare_url":"https://api.github.com/repos/mzabaluev/rust/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mzabaluev/rust/merges","archive_url":"https://api.github.com/repos/mzabaluev/rust/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mzabaluev/rust/downloads","issues_url":"https://api.github.com/repos/mzabaluev/rust/issues{/number}","pulls_url":"https://api.github.com/repos/mzabaluev/rust/pulls{/number}","milestones_url":"https://api.github.com/repos/mzabaluev/rust/milestones{/number}","notifications_url":"https://api.github.com/repos/mzabaluev/rust/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mzabaluev/rust/labels{/name}","releases_url":"https://api.github.com/repos/mzabaluev/rust/releases{/id}","created_at":"2015-02-03T09:33:59Z","updated_at":"2015-04-23T06:21:24Z","pushed_at":"2015-05-30T12:10:09Z","git_url":"git://github.com/mzabaluev/rust.git","ssh_url":"git@github.com:mzabaluev/rust.git","clone_url":"https://github.com/mzabaluev/rust.git","svn_url":"https://github.com/mzabaluev/rust","homepage":"http://www.rust-lang.org","size":292633,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rust-lang:master","ref":"master","sha":"dcc6ce2c772cb851ac35cbc2ddafcae9bf2fa9fd","user":{"login":"rust-lang","id":5430905,"avatar_url":"https://avatars.githubusercontent.com/u/5430905?v=3","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,"name":"rust","full_name":"rust-lang/rust","owner":{"login":"rust-lang","id":5430905,"avatar_url":"https://avatars.githubusercontent.com/u/5430905?v=3","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},"private":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}","created_at":"2010-06-16T20:39:03Z","updated_at":"2015-06-16T21:19:28Z","pushed_at":"2015-06-16T23:07:17Z","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":"http://www.rust-lang.org","size":625520,"stargazers_count":12246,"watchers_count":12246,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2352,"mirror_url":null,"open_issues_count":2124,"forks":2352,"open_issues":2124,"watchers":12246,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/22681"},"html":{"href":"https://github.com/rust-lang/rust/pull/22681"},"issue":{"href":"https://api.github.com/repos/rust-lang/rust/issues/22681"},"comments":{"href":"https://api.github.com/repos/rust-lang/rust/issues/22681/comments"},"review_comments":{"href":"https://api.github.com/repos/rust-lang/rust/pulls/22681/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/22681/commits"},"statuses":{"href":"https://api.github.com/repos/rust-lang/rust/statuses/7b464d364b33915b88f67213a3329e0a3d997e4d"}}}}