{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/corefxlab/pulls/comments/175177732","pull_request_review_id":104672804,"id":175177732,"diff_hunk":"@@ -0,0 +1,114 @@\n+// Licensed to the .NET Foundation under one or more agreements.\n+// The .NET Foundation licenses this file to you under the MIT license.\n+// See the LICENSE file in the project root for more information.\n+\n+using System.Buffers.Text;\n+using System.Runtime.CompilerServices;\n+\n+namespace System.Buffers.Writer\n+{\n+    public ref partial struct BufferWriter<T> where T : IBufferWriter<byte>\n+    {\n+        [MethodImpl(MethodImplOptions.AggressiveInlining)]\n+        public void Write(int value, StandardFormat format = default)\n+        {\n+            int written;\n+            while (!Utf8Formatter.TryFormat(value, Buffer, out written, format))\n+            {\n+                Enlarge();\n+            }\n+            Advance(written);\n+        }\n+\n+        [MethodImpl(MethodImplOptions.AggressiveInlining)]\n+        public void Write(ulong value, StandardFormat format = default)\n+        {\n+            int written;\n+            while (!Utf8Formatter.TryFormat(value, Buffer, out written, format))\n+            {\n+                Enlarge();\n+            }\n+            Advance(written);\n+        }\n+\n+        public void Write(string value)\n+        {\n+            var utf16Bytes = value.AsSpan().AsBytes();","path":"src/System.Buffers.ReaderWriter/System/Buffers/Writer/OutputWriter_overloads.cs","position":36,"original_position":36,"commit_id":"aeeda1968f784bd59520849e1ccfd5182f443cc4","original_commit_id":"aeeda1968f784bd59520849e1ccfd5182f443cc4","user":{"login":"ahsonkhan","id":6527137,"avatar_url":"https://avatars1.githubusercontent.com/u/6527137?v=4","gravatar_id":"","url":"https://api.github.com/users/ahsonkhan","html_url":"https://github.com/ahsonkhan","followers_url":"https://api.github.com/users/ahsonkhan/followers","following_url":"https://api.github.com/users/ahsonkhan/following{/other_user}","gists_url":"https://api.github.com/users/ahsonkhan/gists{/gist_id}","starred_url":"https://api.github.com/users/ahsonkhan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahsonkhan/subscriptions","organizations_url":"https://api.github.com/users/ahsonkhan/orgs","repos_url":"https://api.github.com/users/ahsonkhan/repos","events_url":"https://api.github.com/users/ahsonkhan/events{/privacy}","received_events_url":"https://api.github.com/users/ahsonkhan/received_events","type":"User","site_admin":false},"body":"nit: remove use of var","created_at":"2018-03-16T18:25:23Z","updated_at":"2018-03-16T18:25:23Z","html_url":"https://github.com/dotnet/corefxlab/pull/2163#discussion_r175177732","pull_request_url":"https://api.github.com/repos/dotnet/corefxlab/pulls/2163","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/dotnet/corefxlab/pulls/comments/175177732"},"html":{"href":"https://github.com/dotnet/corefxlab/pull/2163#discussion_r175177732"},"pull_request":{"href":"https://api.github.com/repos/dotnet/corefxlab/pulls/2163"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/corefxlab/pulls/2163","id":175598103,"html_url":"https://github.com/dotnet/corefxlab/pull/2163","diff_url":"https://github.com/dotnet/corefxlab/pull/2163.diff","patch_url":"https://github.com/dotnet/corefxlab/pull/2163.patch","issue_url":"https://api.github.com/repos/dotnet/corefxlab/issues/2163","number":2163,"state":"open","locked":false,"title":"Unified OutputWriter and BufferWriter","user":{"login":"KrzysztofCwalina","id":9724236,"avatar_url":"https://avatars0.githubusercontent.com/u/9724236?v=4","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":"cc: @ahsonkhan, @davidfowl, @joshfree \r\n\r\nI used the implementation of basic writer logic (fields, Advance, Ensure, etc.) from https://github.com/aspnet/benchmarks/tree/dev/src/PlatformBenchmarks\r\n\r\nAdded the ability to write ints and IWritables from the removed BufferWriter.\r\n\r\nThe perf results are super close (probably within the margin of error). Once the writer and Utf8String are in corefx, I think we will be able to switch the ProtformBenchmark implementation to use these.\r\n\r\n\r\n Benchmarks.dll                               | Metric               | Unit  | Iterations |    Average |    STDEV.S |        Min |        Max\r\n:-------------------------------------------- |:-------------------- |:-----:|:----------:| ----------:| ----------:| ----------:| ----------:\r\n BufferWriterBench.BufferWriterCopyPlaintext  | Duration             | msec  |    100     |     49.239 |      3.057 |     44.772 |     66.541\r\n BufferWriterBench.BufferWriterCopyPlaintext  | Instructions Retired | count |    100     | 6.473E+008 | 1.190E+006 | 6.460E+008 | 6.550E+008\r\n BufferWriterBench.BufferWriterCopyPlaintext  | Cache Misses         | count |    100     |  81633.280 |  14440.590 |  49152.000 | 1.270E+005\r\n BufferWriterBench.BufferWriterPlaintext      | Duration             | msec  |    100     |     54.272 |      4.365 |     49.248 |     71.213\r\n BufferWriterBench.BufferWriterPlaintext      | Instructions Retired | count |    100     | 6.531E+008 | 1.972E+006 | 6.500E+008 | 6.620E+008\r\n BufferWriterBench.BufferWriterPlaintext      | Cache Misses         | count |    100     |  96788.480 |  26961.004 |  53248.000 | 1.720E+005\r\n BufferWriterBench.BufferWriterPlaintextUtf8  | Duration             | msec  |    100     |     52.471 |      1.981 |     49.635 |     60.774\r\n BufferWriterBench.BufferWriterPlaintextUtf8  | Instructions Retired | count |    100     | 6.534E+008 | 1.017E+006 | 6.520E+008 | 6.560E+008\r\n BufferWriterBench.BufferWriterPlaintextUtf8  | Cache Misses         | count |    100     |  86548.480 |  17207.879 |  57344.000 | 1.475E+005\r\n BufferWriterBench.PlatfromBenchmarkPlaintext | Duration             | msec  |    100     |     50.390 |      2.965 |     46.137 |     65.976\r\n BufferWriterBench.PlatfromBenchmarkPlaintext | Instructions Retired | count |    100     | 6.601E+008 | 1.348E+006 | 6.580E+008 | 6.650E+008\r\n BufferWriterBench.PlatfromBenchmarkPlaintext | Cache Misses         | count |    100     |  86425.600 |  21449.999 |  53248.000 | 1.516E+005","created_at":"2018-03-16T17:26:18Z","updated_at":"2018-03-16T18:25:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"be9ab80b456c51c353794fff514f25028c3651b8","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/corefxlab/pulls/2163/commits","review_comments_url":"https://api.github.com/repos/dotnet/corefxlab/pulls/2163/comments","review_comment_url":"https://api.github.com/repos/dotnet/corefxlab/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/corefxlab/issues/2163/comments","statuses_url":"https://api.github.com/repos/dotnet/corefxlab/statuses/aeeda1968f784bd59520849e1ccfd5182f443cc4","head":{"label":"KrzysztofCwalina:UnifyWriters","ref":"UnifyWriters","sha":"aeeda1968f784bd59520849e1ccfd5182f443cc4","user":{"login":"KrzysztofCwalina","id":9724236,"avatar_url":"https://avatars0.githubusercontent.com/u/9724236?v=4","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://avatars0.githubusercontent.com/u/9724236?v=4","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":"2018-03-16T12:27:53Z","pushed_at":"2018-03-16T17:43:21Z","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":54579,"stargazers_count":1,"watchers_count":1,"language":"C#","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"dotnet:master","ref":"master","sha":"3a2a16511193822e54014ad767228ed7e512771f","user":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars0.githubusercontent.com/u/9141961?v=4","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://avatars0.githubusercontent.com/u/9141961?v=4","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":"2018-03-16T12:28:17Z","pushed_at":"2018-03-16T17:43:22Z","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":54743,"stargazers_count":1059,"watchers_count":1059,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":270,"mirror_url":null,"archived":false,"open_issues_count":223,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":270,"open_issues":223,"watchers":1059,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/corefxlab/pulls/2163"},"html":{"href":"https://github.com/dotnet/corefxlab/pull/2163"},"issue":{"href":"https://api.github.com/repos/dotnet/corefxlab/issues/2163"},"comments":{"href":"https://api.github.com/repos/dotnet/corefxlab/issues/2163/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/corefxlab/pulls/2163/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/corefxlab/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/corefxlab/pulls/2163/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/corefxlab/statuses/aeeda1968f784bd59520849e1ccfd5182f443cc4"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"ahsonkhan"}}