{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/corefx/pulls/comments/27350598","id":27350598,"diff_hunk":"@@ -0,0 +1,62 @@\n+﻿\n+using System.Collections.Generic;\n+\n+namespace System.Linq\n+{\n+    public static partial class Enumerable\n+    {\n+        internal abstract class SelectWithCountIterator<TSource> : SelectIterator<TSource>, ICollection<TSource>","path":"src/System.Linq/src/System/Linq/Enumerable.SelectWithCountIterator.cs","position":8,"original_position":8,"commit_id":"ff3c0b72aefa5ad02d4931eef1cbe5f57143b60a","original_commit_id":"ff3c0b72aefa5ad02d4931eef1cbe5f57143b60a","user":{"login":"MarcinJuraszek","id":6841973,"avatar_url":"https://avatars.githubusercontent.com/u/6841973?v=3","gravatar_id":"","url":"https://api.github.com/users/MarcinJuraszek","html_url":"https://github.com/MarcinJuraszek","followers_url":"https://api.github.com/users/MarcinJuraszek/followers","following_url":"https://api.github.com/users/MarcinJuraszek/following{/other_user}","gists_url":"https://api.github.com/users/MarcinJuraszek/gists{/gist_id}","starred_url":"https://api.github.com/users/MarcinJuraszek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MarcinJuraszek/subscriptions","organizations_url":"https://api.github.com/users/MarcinJuraszek/orgs","repos_url":"https://api.github.com/users/MarcinJuraszek/repos","events_url":"https://api.github.com/users/MarcinJuraszek/events{/privacy}","received_events_url":"https://api.github.com/users/MarcinJuraszek/received_events","type":"User","site_admin":false},"body":"I don't like the name, but couldn't come up with anything better. Thoughts?","created_at":"2015-03-29T01:45:31Z","updated_at":"2015-03-29T01:45:31Z","html_url":"https://github.com/dotnet/corefx/pull/1282#discussion_r27350598","pull_request_url":"https://api.github.com/repos/dotnet/corefx/pulls/1282","_links":{"self":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/comments/27350598"},"html":{"href":"https://github.com/dotnet/corefx/pull/1282#discussion_r27350598"},"pull_request":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/1282"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/corefx/pulls/1282","id":32174842,"html_url":"https://github.com/dotnet/corefx/pull/1282","diff_url":"https://github.com/dotnet/corefx/pull/1282.diff","patch_url":"https://github.com/dotnet/corefx/pull/1282.patch","issue_url":"https://api.github.com/repos/dotnet/corefx/issues/1282","number":1282,"state":"open","locked":false,"title":"Performance improvements for Enumerable.Select","user":{"login":"MarcinJuraszek","id":6841973,"avatar_url":"https://avatars.githubusercontent.com/u/6841973?v=3","gravatar_id":"","url":"https://api.github.com/users/MarcinJuraszek","html_url":"https://github.com/MarcinJuraszek","followers_url":"https://api.github.com/users/MarcinJuraszek/followers","following_url":"https://api.github.com/users/MarcinJuraszek/following{/other_user}","gists_url":"https://api.github.com/users/MarcinJuraszek/gists{/gist_id}","starred_url":"https://api.github.com/users/MarcinJuraszek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MarcinJuraszek/subscriptions","organizations_url":"https://api.github.com/users/MarcinJuraszek/orgs","repos_url":"https://api.github.com/users/MarcinJuraszek/repos","events_url":"https://api.github.com/users/MarcinJuraszek/events{/privacy}","received_events_url":"https://api.github.com/users/MarcinJuraszek/received_events","type":"User","site_admin":false},"body":"## Problem statement\r\n\r\nRight now `Select()` called on `T[]` array, `List<T>` list and any collection that implements `ICollection<T>` doesn't use the fact that number of items in result collection is known (as projection doesn't change number of items). Because of that calls like:\r\n\r\n    var result = source.Select(x => x + 1).ToList();\r\n\r\ncannot optimize new list creation by initializing it with required capacity, because `Count` is lost by `Select` call. \r\n\r\nThis pull request addresses that issue and is part of bigger effort around LINQ to Objects performance: https://github.com/dotnet/corefx/issues/1182\r\n\r\n## Performance test results\r\n\r\n|                                    | Old    | New    | Improvement |\r\n|------------------------------------|--------|--------|:-----------:|\r\n| **Select() - T[]**                     | 13.38s | 7.93s  |    -40.7%   |\r\n| **Select() - ICollection<T>**          | 17.96  | 14.31s |    -20.3%   |\r\n| **Select() - IEnumerable<T>**          | 18.59s | 19.34s |    +04.0%   |\r\n| **Select().Select() - T[]**            | 22.74s | 11.99s |    -47.3%   |\r\n| **Select().Select() - ICollection<T>** | 30.73s | 17.80s |    -42.1%   |\r\n| **Select().Select() - IEnumerable<T>** | 30.13s | 22.31s |    -25.9%   |\r\n\r\nThere is substantial (20%-47%) performance gain for almost all cases. Single `Select` call on `IEnumerable<T>` is a bit (4%) slower than with existing code.\r\n\r\n## Risk assessment\r\n\r\nPotential drawbacks of the change:\r\n- Iterators returned for `Select` call will be castable to additional interfaces\r\n- If source type implements `Count` incorrectly or performance of `Count` is bad the change might make using `Select `on those types slower or incorrect.","created_at":"2015-03-29T01:44:12Z","updated_at":"2015-03-29T01:45:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bc4f80c2885268510cb8b543bf4a536d4053429f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/corefx/pulls/1282/commits","review_comments_url":"https://api.github.com/repos/dotnet/corefx/pulls/1282/comments","review_comment_url":"https://api.github.com/repos/dotnet/corefx/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/corefx/issues/1282/comments","statuses_url":"https://api.github.com/repos/dotnet/corefx/statuses/ff3c0b72aefa5ad02d4931eef1cbe5f57143b60a","head":{"label":"MarcinJuraszek:linq-select-perf","ref":"linq-select-perf","sha":"ff3c0b72aefa5ad02d4931eef1cbe5f57143b60a","user":{"login":"MarcinJuraszek","id":6841973,"avatar_url":"https://avatars.githubusercontent.com/u/6841973?v=3","gravatar_id":"","url":"https://api.github.com/users/MarcinJuraszek","html_url":"https://github.com/MarcinJuraszek","followers_url":"https://api.github.com/users/MarcinJuraszek/followers","following_url":"https://api.github.com/users/MarcinJuraszek/following{/other_user}","gists_url":"https://api.github.com/users/MarcinJuraszek/gists{/gist_id}","starred_url":"https://api.github.com/users/MarcinJuraszek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MarcinJuraszek/subscriptions","organizations_url":"https://api.github.com/users/MarcinJuraszek/orgs","repos_url":"https://api.github.com/users/MarcinJuraszek/repos","events_url":"https://api.github.com/users/MarcinJuraszek/events{/privacy}","received_events_url":"https://api.github.com/users/MarcinJuraszek/received_events","type":"User","site_admin":false},"repo":{"id":32566576,"name":"corefx","full_name":"MarcinJuraszek/corefx","owner":{"login":"MarcinJuraszek","id":6841973,"avatar_url":"https://avatars.githubusercontent.com/u/6841973?v=3","gravatar_id":"","url":"https://api.github.com/users/MarcinJuraszek","html_url":"https://github.com/MarcinJuraszek","followers_url":"https://api.github.com/users/MarcinJuraszek/followers","following_url":"https://api.github.com/users/MarcinJuraszek/following{/other_user}","gists_url":"https://api.github.com/users/MarcinJuraszek/gists{/gist_id}","starred_url":"https://api.github.com/users/MarcinJuraszek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MarcinJuraszek/subscriptions","organizations_url":"https://api.github.com/users/MarcinJuraszek/orgs","repos_url":"https://api.github.com/users/MarcinJuraszek/repos","events_url":"https://api.github.com/users/MarcinJuraszek/events{/privacy}","received_events_url":"https://api.github.com/users/MarcinJuraszek/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/MarcinJuraszek/corefx","description":"This repo contains the .NET Core foundational libraries, called CoreFX. It includes classes for collections, file systems, console, XML, async and many others.","fork":true,"url":"https://api.github.com/repos/MarcinJuraszek/corefx","forks_url":"https://api.github.com/repos/MarcinJuraszek/corefx/forks","keys_url":"https://api.github.com/repos/MarcinJuraszek/corefx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MarcinJuraszek/corefx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MarcinJuraszek/corefx/teams","hooks_url":"https://api.github.com/repos/MarcinJuraszek/corefx/hooks","issue_events_url":"https://api.github.com/repos/MarcinJuraszek/corefx/issues/events{/number}","events_url":"https://api.github.com/repos/MarcinJuraszek/corefx/events","assignees_url":"https://api.github.com/repos/MarcinJuraszek/corefx/assignees{/user}","branches_url":"https://api.github.com/repos/MarcinJuraszek/corefx/branches{/branch}","tags_url":"https://api.github.com/repos/MarcinJuraszek/corefx/tags","blobs_url":"https://api.github.com/repos/MarcinJuraszek/corefx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MarcinJuraszek/corefx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MarcinJuraszek/corefx/git/refs{/sha}","trees_url":"https://api.github.com/repos/MarcinJuraszek/corefx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MarcinJuraszek/corefx/statuses/{sha}","languages_url":"https://api.github.com/repos/MarcinJuraszek/corefx/languages","stargazers_url":"https://api.github.com/repos/MarcinJuraszek/corefx/stargazers","contributors_url":"https://api.github.com/repos/MarcinJuraszek/corefx/contributors","subscribers_url":"https://api.github.com/repos/MarcinJuraszek/corefx/subscribers","subscription_url":"https://api.github.com/repos/MarcinJuraszek/corefx/subscription","commits_url":"https://api.github.com/repos/MarcinJuraszek/corefx/commits{/sha}","git_commits_url":"https://api.github.com/repos/MarcinJuraszek/corefx/git/commits{/sha}","comments_url":"https://api.github.com/repos/MarcinJuraszek/corefx/comments{/number}","issue_comment_url":"https://api.github.com/repos/MarcinJuraszek/corefx/issues/comments{/number}","contents_url":"https://api.github.com/repos/MarcinJuraszek/corefx/contents/{+path}","compare_url":"https://api.github.com/repos/MarcinJuraszek/corefx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MarcinJuraszek/corefx/merges","archive_url":"https://api.github.com/repos/MarcinJuraszek/corefx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MarcinJuraszek/corefx/downloads","issues_url":"https://api.github.com/repos/MarcinJuraszek/corefx/issues{/number}","pulls_url":"https://api.github.com/repos/MarcinJuraszek/corefx/pulls{/number}","milestones_url":"https://api.github.com/repos/MarcinJuraszek/corefx/milestones{/number}","notifications_url":"https://api.github.com/repos/MarcinJuraszek/corefx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MarcinJuraszek/corefx/labels{/name}","releases_url":"https://api.github.com/repos/MarcinJuraszek/corefx/releases{/id}","created_at":"2015-03-20T06:25:41Z","updated_at":"2015-03-20T06:25:50Z","pushed_at":"2015-03-29T01:29:42Z","git_url":"git://github.com/MarcinJuraszek/corefx.git","ssh_url":"git@github.com:MarcinJuraszek/corefx.git","clone_url":"https://github.com/MarcinJuraszek/corefx.git","svn_url":"https://github.com/MarcinJuraszek/corefx","homepage":"","size":12394,"stargazers_count":0,"watchers_count":0,"language":"C#","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":"dotnet:master","ref":"master","sha":"d0fd58b760cbfaa72837ad10625d5cd76a660dce","user":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"repo":{"id":26295345,"name":"corefx","full_name":"dotnet/corefx","owner":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dotnet/corefx","description":"This repo contains the .NET Core foundational libraries, called CoreFX. It includes classes for collections, file systems, console, XML, async and many others.","fork":false,"url":"https://api.github.com/repos/dotnet/corefx","forks_url":"https://api.github.com/repos/dotnet/corefx/forks","keys_url":"https://api.github.com/repos/dotnet/corefx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/corefx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/corefx/teams","hooks_url":"https://api.github.com/repos/dotnet/corefx/hooks","issue_events_url":"https://api.github.com/repos/dotnet/corefx/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/corefx/events","assignees_url":"https://api.github.com/repos/dotnet/corefx/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/corefx/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/corefx/tags","blobs_url":"https://api.github.com/repos/dotnet/corefx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/corefx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/corefx/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/corefx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/corefx/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/corefx/languages","stargazers_url":"https://api.github.com/repos/dotnet/corefx/stargazers","contributors_url":"https://api.github.com/repos/dotnet/corefx/contributors","subscribers_url":"https://api.github.com/repos/dotnet/corefx/subscribers","subscription_url":"https://api.github.com/repos/dotnet/corefx/subscription","commits_url":"https://api.github.com/repos/dotnet/corefx/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/corefx/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/corefx/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/corefx/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/corefx/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/corefx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/corefx/merges","archive_url":"https://api.github.com/repos/dotnet/corefx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/corefx/downloads","issues_url":"https://api.github.com/repos/dotnet/corefx/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/corefx/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/corefx/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/corefx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/corefx/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/corefx/releases{/id}","created_at":"2014-11-06T23:42:48Z","updated_at":"2015-03-29T00:45:23Z","pushed_at":"2015-03-29T01:44:12Z","git_url":"git://github.com/dotnet/corefx.git","ssh_url":"git@github.com:dotnet/corefx.git","clone_url":"https://github.com/dotnet/corefx.git","svn_url":"https://github.com/dotnet/corefx","homepage":"","size":30670,"stargazers_count":7319,"watchers_count":7319,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1412,"mirror_url":null,"open_issues_count":314,"forks":1412,"open_issues":314,"watchers":7319,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/1282"},"html":{"href":"https://github.com/dotnet/corefx/pull/1282"},"issue":{"href":"https://api.github.com/repos/dotnet/corefx/issues/1282"},"comments":{"href":"https://api.github.com/repos/dotnet/corefx/issues/1282/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/1282/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/1282/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/corefx/statuses/ff3c0b72aefa5ad02d4931eef1cbe5f57143b60a"}}}}