{"action":"created","comment":{"url":"https://api.github.com/repos/twitter/util/pulls/comments/80273222","id":80273222,"diff_hunk":"@@ -6,28 +6,36 @@ import scala.annotation.tailrec\n \n object StreamIO {\n   /**\n-   * Copy an InputStream to an OutputStream in chunks of the given\n-   * buffer size (default = 1KB).\n-   */\n-  @tailrec\n+    * Copy an InputStream to an OutputStream in chunks of the given\n+    * buffer size (default = 1KB).\n+    */\n   final def copy(\n-    inputStream:  InputStream,\n-    outputStream: OutputStream,\n-    bufferSize:   Int = 1024\n-  ) {\n-    val buf = new Array[Byte](bufferSize)\n-    inputStream.read(buf, 0, buf.length) match {\n+                  inputStream: InputStream,\n+                  outputStream: OutputStream,\n+                  bufferSize: Int = 1024\n+                ) {\n+    val buffer = new Array[Byte](bufferSize)\n+    copy(inputStream, outputStream, buffer)\n+  }\n+\n+  @tailrec\n+  final private def copy(\n+                  inputStream: InputStream,\n+                  outputStream: OutputStream,\n+                  buffer: Array[Byte]\n+                ) {\n+    inputStream.read(buffer, 0, buffer.length) match {\n       case -1 => ()\n       case n =>\n-        outputStream.write(buf, 0, n)\n-        copy(inputStream, outputStream, bufferSize)\n+        outputStream.write(buffer, 0, n)\n+        copy(inputStream, outputStream, buffer)\n     }\n   }\n \n   /**\n-   * Buffer (fully) the given input stream by creating & copying it to\n-   * a ByteArrayOutputStream.\n-   */\n+    * Buffer (fully) the given input stream by creating & copying it to","path":"util-core/src/main/scala/com/twitter/io/StreamIO.scala","position":46,"original_position":46,"commit_id":"4bfac34f1f2363653885bdff18c80b4d59777e5b","original_commit_id":"4bfac34f1f2363653885bdff18c80b4d59777e5b","user":{"login":"mosesn","id":156562,"avatar_url":"https://avatars.githubusercontent.com/u/156562?v=3","gravatar_id":"","url":"https://api.github.com/users/mosesn","html_url":"https://github.com/mosesn","followers_url":"https://api.github.com/users/mosesn/followers","following_url":"https://api.github.com/users/mosesn/following{/other_user}","gists_url":"https://api.github.com/users/mosesn/gists{/gist_id}","starred_url":"https://api.github.com/users/mosesn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mosesn/subscriptions","organizations_url":"https://api.github.com/users/mosesn/orgs","repos_url":"https://api.github.com/users/mosesn/repos","events_url":"https://api.github.com/users/mosesn/events{/privacy}","received_events_url":"https://api.github.com/users/mosesn/received_events","type":"User","site_admin":false},"body":"keep stars aligned to the left star (-1 col)","created_at":"2016-09-23T15:56:54Z","updated_at":"2016-09-23T15:57:18Z","html_url":"https://github.com/twitter/util/pull/175#discussion_r80273222","pull_request_url":"https://api.github.com/repos/twitter/util/pulls/175","_links":{"self":{"href":"https://api.github.com/repos/twitter/util/pulls/comments/80273222"},"html":{"href":"https://github.com/twitter/util/pull/175#discussion_r80273222"},"pull_request":{"href":"https://api.github.com/repos/twitter/util/pulls/175"}}},"pull_request":{"url":"https://api.github.com/repos/twitter/util/pulls/175","id":86461137,"html_url":"https://github.com/twitter/util/pull/175","diff_url":"https://github.com/twitter/util/pull/175.diff","patch_url":"https://github.com/twitter/util/pull/175.patch","issue_url":"https://api.github.com/repos/twitter/util/issues/175","number":175,"state":"open","locked":false,"title":"enhance copy to reuse buffer","user":{"login":"zkidkid","id":1466544,"avatar_url":"https://avatars.githubusercontent.com/u/1466544?v=3","gravatar_id":"","url":"https://api.github.com/users/zkidkid","html_url":"https://github.com/zkidkid","followers_url":"https://api.github.com/users/zkidkid/followers","following_url":"https://api.github.com/users/zkidkid/following{/other_user}","gists_url":"https://api.github.com/users/zkidkid/gists{/gist_id}","starred_url":"https://api.github.com/users/zkidkid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zkidkid/subscriptions","organizations_url":"https://api.github.com/users/zkidkid/orgs","repos_url":"https://api.github.com/users/zkidkid/repos","events_url":"https://api.github.com/users/zkidkid/events{/privacy}","received_events_url":"https://api.github.com/users/zkidkid/received_events","type":"User","site_admin":false},"body":"Problem\r\n\r\nEnhance StreamIO::copy function by re-use tmp buffer.\r\n\r\nSolution\r\n\r\nCreate temp buffer before calling recursive function. \r\n\r\n","created_at":"2016-09-23T06:41:53Z","updated_at":"2016-09-23T15:57:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"96923b11bdf80292a0776e711309d7c5347b1f7a","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/twitter/util/pulls/175/commits","review_comments_url":"https://api.github.com/repos/twitter/util/pulls/175/comments","review_comment_url":"https://api.github.com/repos/twitter/util/pulls/comments{/number}","comments_url":"https://api.github.com/repos/twitter/util/issues/175/comments","statuses_url":"https://api.github.com/repos/twitter/util/statuses/4bfac34f1f2363653885bdff18c80b4d59777e5b","head":{"label":"zkidkid:streamio-fix-copy","ref":"streamio-fix-copy","sha":"4bfac34f1f2363653885bdff18c80b4d59777e5b","user":{"login":"zkidkid","id":1466544,"avatar_url":"https://avatars.githubusercontent.com/u/1466544?v=3","gravatar_id":"","url":"https://api.github.com/users/zkidkid","html_url":"https://github.com/zkidkid","followers_url":"https://api.github.com/users/zkidkid/followers","following_url":"https://api.github.com/users/zkidkid/following{/other_user}","gists_url":"https://api.github.com/users/zkidkid/gists{/gist_id}","starred_url":"https://api.github.com/users/zkidkid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zkidkid/subscriptions","organizations_url":"https://api.github.com/users/zkidkid/orgs","repos_url":"https://api.github.com/users/zkidkid/repos","events_url":"https://api.github.com/users/zkidkid/events{/privacy}","received_events_url":"https://api.github.com/users/zkidkid/received_events","type":"User","site_admin":false},"repo":{"id":68988286,"name":"util","full_name":"zkidkid/util","owner":{"login":"zkidkid","id":1466544,"avatar_url":"https://avatars.githubusercontent.com/u/1466544?v=3","gravatar_id":"","url":"https://api.github.com/users/zkidkid","html_url":"https://github.com/zkidkid","followers_url":"https://api.github.com/users/zkidkid/followers","following_url":"https://api.github.com/users/zkidkid/following{/other_user}","gists_url":"https://api.github.com/users/zkidkid/gists{/gist_id}","starred_url":"https://api.github.com/users/zkidkid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zkidkid/subscriptions","organizations_url":"https://api.github.com/users/zkidkid/orgs","repos_url":"https://api.github.com/users/zkidkid/repos","events_url":"https://api.github.com/users/zkidkid/events{/privacy}","received_events_url":"https://api.github.com/users/zkidkid/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/zkidkid/util","description":"Wonderful reusable code from Twitter","fork":true,"url":"https://api.github.com/repos/zkidkid/util","forks_url":"https://api.github.com/repos/zkidkid/util/forks","keys_url":"https://api.github.com/repos/zkidkid/util/keys{/key_id}","collaborators_url":"https://api.github.com/repos/zkidkid/util/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/zkidkid/util/teams","hooks_url":"https://api.github.com/repos/zkidkid/util/hooks","issue_events_url":"https://api.github.com/repos/zkidkid/util/issues/events{/number}","events_url":"https://api.github.com/repos/zkidkid/util/events","assignees_url":"https://api.github.com/repos/zkidkid/util/assignees{/user}","branches_url":"https://api.github.com/repos/zkidkid/util/branches{/branch}","tags_url":"https://api.github.com/repos/zkidkid/util/tags","blobs_url":"https://api.github.com/repos/zkidkid/util/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/zkidkid/util/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/zkidkid/util/git/refs{/sha}","trees_url":"https://api.github.com/repos/zkidkid/util/git/trees{/sha}","statuses_url":"https://api.github.com/repos/zkidkid/util/statuses/{sha}","languages_url":"https://api.github.com/repos/zkidkid/util/languages","stargazers_url":"https://api.github.com/repos/zkidkid/util/stargazers","contributors_url":"https://api.github.com/repos/zkidkid/util/contributors","subscribers_url":"https://api.github.com/repos/zkidkid/util/subscribers","subscription_url":"https://api.github.com/repos/zkidkid/util/subscription","commits_url":"https://api.github.com/repos/zkidkid/util/commits{/sha}","git_commits_url":"https://api.github.com/repos/zkidkid/util/git/commits{/sha}","comments_url":"https://api.github.com/repos/zkidkid/util/comments{/number}","issue_comment_url":"https://api.github.com/repos/zkidkid/util/issues/comments{/number}","contents_url":"https://api.github.com/repos/zkidkid/util/contents/{+path}","compare_url":"https://api.github.com/repos/zkidkid/util/compare/{base}...{head}","merges_url":"https://api.github.com/repos/zkidkid/util/merges","archive_url":"https://api.github.com/repos/zkidkid/util/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/zkidkid/util/downloads","issues_url":"https://api.github.com/repos/zkidkid/util/issues{/number}","pulls_url":"https://api.github.com/repos/zkidkid/util/pulls{/number}","milestones_url":"https://api.github.com/repos/zkidkid/util/milestones{/number}","notifications_url":"https://api.github.com/repos/zkidkid/util/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/zkidkid/util/labels{/name}","releases_url":"https://api.github.com/repos/zkidkid/util/releases{/id}","deployments_url":"https://api.github.com/repos/zkidkid/util/deployments","created_at":"2016-09-23T04:17:47Z","updated_at":"2016-09-23T04:17:49Z","pushed_at":"2016-09-23T06:29:59Z","git_url":"git://github.com/zkidkid/util.git","ssh_url":"git@github.com:zkidkid/util.git","clone_url":"https://github.com/zkidkid/util.git","svn_url":"https://github.com/zkidkid/util","homepage":"http://twitter.github.com/util","size":11969,"stargazers_count":0,"watchers_count":0,"language":"Scala","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":"develop"}},"base":{"label":"twitter:develop","ref":"develop","sha":"fdf10fa481e6cd20e9a8a00cec31e5be55793727","user":{"login":"twitter","id":50278,"avatar_url":"https://avatars.githubusercontent.com/u/50278?v=3","gravatar_id":"","url":"https://api.github.com/users/twitter","html_url":"https://github.com/twitter","followers_url":"https://api.github.com/users/twitter/followers","following_url":"https://api.github.com/users/twitter/following{/other_user}","gists_url":"https://api.github.com/users/twitter/gists{/gist_id}","starred_url":"https://api.github.com/users/twitter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twitter/subscriptions","organizations_url":"https://api.github.com/users/twitter/orgs","repos_url":"https://api.github.com/users/twitter/repos","events_url":"https://api.github.com/users/twitter/events{/privacy}","received_events_url":"https://api.github.com/users/twitter/received_events","type":"Organization","site_admin":false},"repo":{"id":1527969,"name":"util","full_name":"twitter/util","owner":{"login":"twitter","id":50278,"avatar_url":"https://avatars.githubusercontent.com/u/50278?v=3","gravatar_id":"","url":"https://api.github.com/users/twitter","html_url":"https://github.com/twitter","followers_url":"https://api.github.com/users/twitter/followers","following_url":"https://api.github.com/users/twitter/following{/other_user}","gists_url":"https://api.github.com/users/twitter/gists{/gist_id}","starred_url":"https://api.github.com/users/twitter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twitter/subscriptions","organizations_url":"https://api.github.com/users/twitter/orgs","repos_url":"https://api.github.com/users/twitter/repos","events_url":"https://api.github.com/users/twitter/events{/privacy}","received_events_url":"https://api.github.com/users/twitter/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/twitter/util","description":"Wonderful reusable code from Twitter","fork":false,"url":"https://api.github.com/repos/twitter/util","forks_url":"https://api.github.com/repos/twitter/util/forks","keys_url":"https://api.github.com/repos/twitter/util/keys{/key_id}","collaborators_url":"https://api.github.com/repos/twitter/util/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/twitter/util/teams","hooks_url":"https://api.github.com/repos/twitter/util/hooks","issue_events_url":"https://api.github.com/repos/twitter/util/issues/events{/number}","events_url":"https://api.github.com/repos/twitter/util/events","assignees_url":"https://api.github.com/repos/twitter/util/assignees{/user}","branches_url":"https://api.github.com/repos/twitter/util/branches{/branch}","tags_url":"https://api.github.com/repos/twitter/util/tags","blobs_url":"https://api.github.com/repos/twitter/util/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/twitter/util/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/twitter/util/git/refs{/sha}","trees_url":"https://api.github.com/repos/twitter/util/git/trees{/sha}","statuses_url":"https://api.github.com/repos/twitter/util/statuses/{sha}","languages_url":"https://api.github.com/repos/twitter/util/languages","stargazers_url":"https://api.github.com/repos/twitter/util/stargazers","contributors_url":"https://api.github.com/repos/twitter/util/contributors","subscribers_url":"https://api.github.com/repos/twitter/util/subscribers","subscription_url":"https://api.github.com/repos/twitter/util/subscription","commits_url":"https://api.github.com/repos/twitter/util/commits{/sha}","git_commits_url":"https://api.github.com/repos/twitter/util/git/commits{/sha}","comments_url":"https://api.github.com/repos/twitter/util/comments{/number}","issue_comment_url":"https://api.github.com/repos/twitter/util/issues/comments{/number}","contents_url":"https://api.github.com/repos/twitter/util/contents/{+path}","compare_url":"https://api.github.com/repos/twitter/util/compare/{base}...{head}","merges_url":"https://api.github.com/repos/twitter/util/merges","archive_url":"https://api.github.com/repos/twitter/util/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/twitter/util/downloads","issues_url":"https://api.github.com/repos/twitter/util/issues{/number}","pulls_url":"https://api.github.com/repos/twitter/util/pulls{/number}","milestones_url":"https://api.github.com/repos/twitter/util/milestones{/number}","notifications_url":"https://api.github.com/repos/twitter/util/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/twitter/util/labels{/name}","releases_url":"https://api.github.com/repos/twitter/util/releases{/id}","deployments_url":"https://api.github.com/repos/twitter/util/deployments","created_at":"2011-03-26T01:23:21Z","updated_at":"2016-09-22T08:24:02Z","pushed_at":"2016-09-23T06:41:53Z","git_url":"git://github.com/twitter/util.git","ssh_url":"git@github.com:twitter/util.git","clone_url":"https://github.com/twitter/util.git","svn_url":"https://github.com/twitter/util","homepage":"http://twitter.github.com/util","size":13369,"stargazers_count":1652,"watchers_count":1652,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":338,"mirror_url":null,"open_issues_count":5,"forks":338,"open_issues":5,"watchers":1652,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/twitter/util/pulls/175"},"html":{"href":"https://github.com/twitter/util/pull/175"},"issue":{"href":"https://api.github.com/repos/twitter/util/issues/175"},"comments":{"href":"https://api.github.com/repos/twitter/util/issues/175/comments"},"review_comments":{"href":"https://api.github.com/repos/twitter/util/pulls/175/comments"},"review_comment":{"href":"https://api.github.com/repos/twitter/util/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/twitter/util/pulls/175/commits"},"statuses":{"href":"https://api.github.com/repos/twitter/util/statuses/4bfac34f1f2363653885bdff18c80b4d59777e5b"}}}}
{"actor":{"display_login":"mosesn"}}