{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/corefxlab/pulls/comments/81666343","pull_request_review_id":2630007,"id":81666343,"diff_hunk":"@@ -1,16 +1,52 @@\n ﻿// Copyright (c) Microsoft. All rights reserved.\n // Licensed under the MIT license. See LICENSE file in the project root for full license information.\n \n-using System;\n-using System.Collections.Generic;\n using System.Collections.Sequences;\n using System.Text;\n \n namespace System.Buffers\n {\n-    public static class MultispanExtensions\n+    public static class ExperimentalSequenceExtensions\n     {\n-        public static bool TryParseUInt32<TMultispan>(this TMultispan bytes, EncodingData encoding, out uint value, out int consumed) where TMultispan : ISpanSequence<byte>\n+        public delegate TResult FuncOfSpan<T, TResult>(Span<T> span);\n+        public delegate void ActionOfSpan<T>(Span<T> span);\n+\n+        public static TResult Do<T, TResult>(this ISpanSequence<T> buffer, FuncOfSpan<T, TResult> function)\n+        {\n+            Span<T> flat;\n+            if (buffer.Count < 2) flat = buffer.Flatten();\n+            if (buffer.TotalLength < 128) {\n+                unsafe\n+                {\n+                    var stackArray = stackalloc byte[128];\n+                    flat = new Span<T>(stackArray, 128);\n+                    if (!buffer.TryCopyTo(ref flat, 0)) {\n+                        throw new Exception(nameof(buffer) + \".TotalLength returned bad value.\");\n+                    }\n+                }\n+            }\n+            else flat = buffer.Flatten();\n+\n+            return function(flat);\n+        }\n+\n+        public static void Do<T>(this ISpanSequence<T> buffer, ActionOfSpan<T> action)\n+        {\n+            Span<T> flat;\n+            if (buffer.Count < 2) flat = buffer.Flatten();\n+            if (buffer.TotalLength < 128) {\n+                unsafe\n+                {\n+                    var stackArray = stackalloc byte[128];\n+                    flat = new Span<T>(stackArray, 128);\n+                }","path":"src/System.Buffers.Experimental/System/Buffers/SequenceExtensions.cs","position":46,"original_position":46,"commit_id":"d80dfa795b1881a1176dc75f884b8b8e17de1159","original_commit_id":"d80dfa795b1881a1176dc75f884b8b8e17de1159","user":{"login":"KrzysztofCwalina","id":9724236,"avatar_url":"https://avatars.githubusercontent.com/u/9724236?v=3","gravatar_id":"","url":"https://api.github.com/users/KrzysztofCwalina","html_url":"https://github.com/KrzysztofCwalina","followers_url":"https://api.github.com/users/KrzysztofCwalina/followers","following_url":"https://api.github.com/users/KrzysztofCwalina/following{/other_user}","gists_url":"https://api.github.com/users/KrzysztofCwalina/gists{/gist_id}","starred_url":"https://api.github.com/users/KrzysztofCwalina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KrzysztofCwalina/subscriptions","organizations_url":"https://api.github.com/users/KrzysztofCwalina/orgs","repos_url":"https://api.github.com/users/KrzysztofCwalina/repos","events_url":"https://api.github.com/users/KrzysztofCwalina/events{/privacy}","received_events_url":"https://api.github.com/users/KrzysztofCwalina/received_events","type":"User","site_admin":false},"body":"Ah, good catch. Fixed in #862","created_at":"2016-10-04T00:08:43Z","updated_at":"2016-10-04T00:08:43Z","html_url":"https://github.com/dotnet/corefxlab/pull/861#discussion_r81666343","pull_request_url":"https://api.github.com/repos/dotnet/corefxlab/pulls/861","_links":{"self":{"href":"https://api.github.com/repos/dotnet/corefxlab/pulls/comments/81666343"},"html":{"href":"https://github.com/dotnet/corefxlab/pull/861#discussion_r81666343"},"pull_request":{"href":"https://api.github.com/repos/dotnet/corefxlab/pulls/861"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/corefxlab/pulls/861","id":87803079,"html_url":"https://github.com/dotnet/corefxlab/pull/861","diff_url":"https://github.com/dotnet/corefxlab/pull/861.diff","patch_url":"https://github.com/dotnet/corefxlab/pull/861.patch","issue_url":"https://api.github.com/repos/dotnet/corefxlab/issues/861","number":861,"state":"closed","locked":false,"title":"Added LINQ-like operations for span sequences.","user":{"login":"KrzysztofCwalina","id":9724236,"avatar_url":"https://avatars.githubusercontent.com/u/9724236?v=3","gravatar_id":"","url":"https://api.github.com/users/KrzysztofCwalina","html_url":"https://github.com/KrzysztofCwalina","followers_url":"https://api.github.com/users/KrzysztofCwalina/followers","following_url":"https://api.github.com/users/KrzysztofCwalina/following{/other_user}","gists_url":"https://api.github.com/users/KrzysztofCwalina/gists{/gist_id}","starred_url":"https://api.github.com/users/KrzysztofCwalina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KrzysztofCwalina/subscriptions","organizations_url":"https://api.github.com/users/KrzysztofCwalina/orgs","repos_url":"https://api.github.com/users/KrzysztofCwalina/repos","events_url":"https://api.github.com/users/KrzysztofCwalina/events{/privacy}","received_events_url":"https://api.github.com/users/KrzysztofCwalina/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-10-03T22:24:07Z","updated_at":"2016-10-04T00:08:43Z","closed_at":"2016-10-03T23:22:07Z","merged_at":"2016-10-03T23:22:07Z","merge_commit_sha":"87ef995bdc6c8bf9d7218688f25922b4f410da82","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/corefxlab/pulls/861/commits","review_comments_url":"https://api.github.com/repos/dotnet/corefxlab/pulls/861/comments","review_comment_url":"https://api.github.com/repos/dotnet/corefxlab/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/corefxlab/issues/861/comments","statuses_url":"https://api.github.com/repos/dotnet/corefxlab/statuses/d80dfa795b1881a1176dc75f884b8b8e17de1159","head":{"label":"KrzysztofCwalina:SequenceExtensions","ref":"SequenceExtensions","sha":"d80dfa795b1881a1176dc75f884b8b8e17de1159","user":{"login":"KrzysztofCwalina","id":9724236,"avatar_url":"https://avatars.githubusercontent.com/u/9724236?v=3","gravatar_id":"","url":"https://api.github.com/users/KrzysztofCwalina","html_url":"https://github.com/KrzysztofCwalina","followers_url":"https://api.github.com/users/KrzysztofCwalina/followers","following_url":"https://api.github.com/users/KrzysztofCwalina/following{/other_user}","gists_url":"https://api.github.com/users/KrzysztofCwalina/gists{/gist_id}","starred_url":"https://api.github.com/users/KrzysztofCwalina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KrzysztofCwalina/subscriptions","organizations_url":"https://api.github.com/users/KrzysztofCwalina/orgs","repos_url":"https://api.github.com/users/KrzysztofCwalina/repos","events_url":"https://api.github.com/users/KrzysztofCwalina/events{/privacy}","received_events_url":"https://api.github.com/users/KrzysztofCwalina/received_events","type":"User","site_admin":false},"repo":{"id":29568039,"name":"corefxlab","full_name":"KrzysztofCwalina/corefxlab","owner":{"login":"KrzysztofCwalina","id":9724236,"avatar_url":"https://avatars.githubusercontent.com/u/9724236?v=3","gravatar_id":"","url":"https://api.github.com/users/KrzysztofCwalina","html_url":"https://github.com/KrzysztofCwalina","followers_url":"https://api.github.com/users/KrzysztofCwalina/followers","following_url":"https://api.github.com/users/KrzysztofCwalina/following{/other_user}","gists_url":"https://api.github.com/users/KrzysztofCwalina/gists{/gist_id}","starred_url":"https://api.github.com/users/KrzysztofCwalina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KrzysztofCwalina/subscriptions","organizations_url":"https://api.github.com/users/KrzysztofCwalina/orgs","repos_url":"https://api.github.com/users/KrzysztofCwalina/repos","events_url":"https://api.github.com/users/KrzysztofCwalina/events{/privacy}","received_events_url":"https://api.github.com/users/KrzysztofCwalina/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/KrzysztofCwalina/corefxlab","description":"This repo is for experimentation and exploring new ideas that may or may not make it into the main corefx repo.","fork":true,"url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab","forks_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/forks","keys_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/keys{/key_id}","collaborators_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/teams","hooks_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/hooks","issue_events_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/issues/events{/number}","events_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/events","assignees_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/assignees{/user}","branches_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/branches{/branch}","tags_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/tags","blobs_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/git/refs{/sha}","trees_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/git/trees{/sha}","statuses_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/statuses/{sha}","languages_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/languages","stargazers_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/stargazers","contributors_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/contributors","subscribers_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/subscribers","subscription_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/subscription","commits_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/commits{/sha}","git_commits_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/git/commits{/sha}","comments_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/comments{/number}","issue_comment_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/issues/comments{/number}","contents_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/contents/{+path}","compare_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/compare/{base}...{head}","merges_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/merges","archive_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/downloads","issues_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/issues{/number}","pulls_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/pulls{/number}","milestones_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/milestones{/number}","notifications_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/labels{/name}","releases_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/releases{/id}","deployments_url":"https://api.github.com/repos/KrzysztofCwalina/corefxlab/deployments","created_at":"2015-01-21T02:57:31Z","updated_at":"2016-01-11T17:11:06Z","pushed_at":"2016-10-04T00:07:17Z","git_url":"git://github.com/KrzysztofCwalina/corefxlab.git","ssh_url":"git@github.com:KrzysztofCwalina/corefxlab.git","clone_url":"https://github.com/KrzysztofCwalina/corefxlab.git","svn_url":"https://github.com/KrzysztofCwalina/corefxlab","homepage":"","size":29446,"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":"006cdc01eedaa99ae9609c27480f55a4529602d5","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":29504192,"name":"corefxlab","full_name":"dotnet/corefxlab","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/corefxlab","description":"This repo is for experimentation and exploring new ideas that may or may not make it into the main corefx repo.","fork":false,"url":"https://api.github.com/repos/dotnet/corefxlab","forks_url":"https://api.github.com/repos/dotnet/corefxlab/forks","keys_url":"https://api.github.com/repos/dotnet/corefxlab/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/corefxlab/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/corefxlab/teams","hooks_url":"https://api.github.com/repos/dotnet/corefxlab/hooks","issue_events_url":"https://api.github.com/repos/dotnet/corefxlab/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/corefxlab/events","assignees_url":"https://api.github.com/repos/dotnet/corefxlab/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/corefxlab/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/corefxlab/tags","blobs_url":"https://api.github.com/repos/dotnet/corefxlab/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/corefxlab/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/corefxlab/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/corefxlab/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/corefxlab/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/corefxlab/languages","stargazers_url":"https://api.github.com/repos/dotnet/corefxlab/stargazers","contributors_url":"https://api.github.com/repos/dotnet/corefxlab/contributors","subscribers_url":"https://api.github.com/repos/dotnet/corefxlab/subscribers","subscription_url":"https://api.github.com/repos/dotnet/corefxlab/subscription","commits_url":"https://api.github.com/repos/dotnet/corefxlab/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/corefxlab/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/corefxlab/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/corefxlab/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/corefxlab/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/corefxlab/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/corefxlab/merges","archive_url":"https://api.github.com/repos/dotnet/corefxlab/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/corefxlab/downloads","issues_url":"https://api.github.com/repos/dotnet/corefxlab/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/corefxlab/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/corefxlab/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/corefxlab/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/corefxlab/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/corefxlab/releases{/id}","deployments_url":"https://api.github.com/repos/dotnet/corefxlab/deployments","created_at":"2015-01-20T00:44:35Z","updated_at":"2016-09-30T23:49:08Z","pushed_at":"2016-10-04T00:07:39Z","git_url":"git://github.com/dotnet/corefxlab.git","ssh_url":"git@github.com:dotnet/corefxlab.git","clone_url":"https://github.com/dotnet/corefxlab.git","svn_url":"https://github.com/dotnet/corefxlab","homepage":"","size":30079,"stargazers_count":362,"watchers_count":362,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":131,"mirror_url":null,"open_issues_count":128,"forks":131,"open_issues":128,"watchers":362,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/corefxlab/pulls/861"},"html":{"href":"https://github.com/dotnet/corefxlab/pull/861"},"issue":{"href":"https://api.github.com/repos/dotnet/corefxlab/issues/861"},"comments":{"href":"https://api.github.com/repos/dotnet/corefxlab/issues/861/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/corefxlab/pulls/861/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/corefxlab/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/corefxlab/pulls/861/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/corefxlab/statuses/d80dfa795b1881a1176dc75f884b8b8e17de1159"}}}}
{"actor":{"display_login":"KrzysztofCwalina"}}