{"action":"created","comment":{"url":"https://api.github.com/repos/scala/scala/pulls/comments/199998647","pull_request_review_id":134226151,"id":199998647,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5OTk5ODY0Nw==","diff_hunk":"@@ -492,39 +494,52 @@ final class StringOps(private val s: String) extends AnyVal {\n     *               the string `sep`.\n     */\n   def mkString(start: String, sep: String, end: String): String =\n-    addString(new mutable.StringBuilder(), start, sep, end).toString\n+    addString(new jStringBuilder(), start, sep, end).toString\n \n   /** Displays all elements of this string in a string using a separator string.\n     *\n     *  @param sep   the separator string.\n     *  @return      In the resulting string\n     *               the chars of this string are separated by the string `sep`.\n     */\n-  def mkString(sep: String): String = mkString(\"\", sep, \"\")\n+  def mkString(sep: String): String =\n+    if (sep.length == 0) s\n+    else mkString(\"\", sep, \"\")\n \n   /** Returns this String */\n   def mkString: String = s\n \n   /** Appends this string to a string builder. */\n-  def addString(b: mutable.StringBuilder): mutable.StringBuilder =\n+  def addString(b: StringBuilder): StringBuilder =\n     b.append(s)\n \n   /** Appends this string to a string builder using a separator string. */\n-  def addString(b: mutable.StringBuilder, sep: String): mutable.StringBuilder =\n+  def addString(b: StringBuilder, sep: String): StringBuilder =\n     addString(b, \"\", sep, \"\")\n \n   /** Appends this string to a string builder using start, end and separator strings. */\n-  def addString(b: mutable.StringBuilder, start: String, sep: String, end: String): mutable.StringBuilder = {\n+  def addString(b: StringBuilder, start: String, sep: String, end: String): StringBuilder = {\n+    addString(b.sb, start, sep, end)\n+    b\n+  }\n+\n+  /** Appends this string to a string builder using start, end and separator strings. */\n+  def addString(b: jStringBuilder, start: String, sep: String, end: String): jStringBuilder = {\n     b.append(start)\n     val len = s.length\n-    var i = 0\n-    while(i < len) {\n-      if(i != 0) b.append(sep)\n-      b.append(s.charAt(i))\n-      i += 1\n+    if (len > 0) {\n+      if (sep.length == 0) b.append(s)\n+      else {\n+        b.append(s.charAt(0))\n+        var i = 1\n+        while (i < len) {","path":"src/library/scala/collection/StringOps.scala","position":147,"original_position":147,"commit_id":"76ec075f7022930bac9d9992a0b0a3050047c0b4","original_commit_id":"76ec075f7022930bac9d9992a0b0a3050047c0b4","user":{"login":"isaacl","id":1027886,"node_id":"MDQ6VXNlcjEwMjc4ODY=","avatar_url":"https://avatars2.githubusercontent.com/u/1027886?v=4","gravatar_id":"","url":"https://api.github.com/users/isaacl","html_url":"https://github.com/isaacl","followers_url":"https://api.github.com/users/isaacl/followers","following_url":"https://api.github.com/users/isaacl/following{/other_user}","gists_url":"https://api.github.com/users/isaacl/gists{/gist_id}","starred_url":"https://api.github.com/users/isaacl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isaacl/subscriptions","organizations_url":"https://api.github.com/users/isaacl/orgs","repos_url":"https://api.github.com/users/isaacl/repos","events_url":"https://api.github.com/users/isaacl/events{/privacy}","received_events_url":"https://api.github.com/users/isaacl/received_events","type":"User","site_admin":false},"body":"I'll run a benchmark.","created_at":"2018-07-04T03:10:13Z","updated_at":"2018-07-04T03:10:13Z","html_url":"https://github.com/scala/scala/pull/6878#discussion_r199998647","pull_request_url":"https://api.github.com/repos/scala/scala/pulls/6878","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/scala/scala/pulls/comments/199998647"},"html":{"href":"https://github.com/scala/scala/pull/6878#discussion_r199998647"},"pull_request":{"href":"https://api.github.com/repos/scala/scala/pulls/6878"}},"in_reply_to_id":199822038},"pull_request":{"url":"https://api.github.com/repos/scala/scala/pulls/6878","id":198728838,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk4NzI4ODM4","html_url":"https://github.com/scala/scala/pull/6878","diff_url":"https://github.com/scala/scala/pull/6878.diff","patch_url":"https://github.com/scala/scala/pull/6878.patch","issue_url":"https://api.github.com/repos/scala/scala/issues/6878","number":6878,"state":"open","locked":false,"title":"[RFC] Optimize mkString and addString","user":{"login":"isaacl","id":1027886,"node_id":"MDQ6VXNlcjEwMjc4ODY=","avatar_url":"https://avatars2.githubusercontent.com/u/1027886?v=4","gravatar_id":"","url":"https://api.github.com/users/isaacl","html_url":"https://github.com/isaacl","followers_url":"https://api.github.com/users/isaacl/followers","following_url":"https://api.github.com/users/isaacl/following{/other_user}","gists_url":"https://api.github.com/users/isaacl/gists{/gist_id}","starred_url":"https://api.github.com/users/isaacl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isaacl/subscriptions","organizations_url":"https://api.github.com/users/isaacl/orgs","repos_url":"https://api.github.com/users/isaacl/repos","events_url":"https://api.github.com/users/isaacl/events{/privacy}","received_events_url":"https://api.github.com/users/isaacl/received_events","type":"User","site_admin":false},"body":"- Short circuit empty collections\n- Switch to java Stringbuilder\n- mark `mkString`/`addString` methods final, create a overridable\n  function\n\nFast path for 1 element is not possible due to some classes wanting\ncustom rendering of single element, such as Map. Possibly could be\nimproved with a custom function for rendering elements that classes can\noverride.\n\nMap(1 -> 1).addString(new StringBuilder).toString recently regressed to\n\"(1, 1)\". This code fixes the regression; I'd like to add a test but not\nsure where to put it.","created_at":"2018-07-02T16:22:15Z","updated_at":"2018-07-04T03:10:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c7ef0922c192b478d3c1e9b05852b4ad13d4c255","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":{"url":"https://api.github.com/repos/scala/scala/milestones/74","html_url":"https://github.com/scala/scala/milestone/74","labels_url":"https://api.github.com/repos/scala/scala/milestones/74/labels","id":3295287,"node_id":"MDk6TWlsZXN0b25lMzI5NTI4Nw==","number":74,"title":"2.13.0-M5","description":"Merge to 2.13.x. Last milestone (feature-frozen; aka RC0).\r\nRelease lead: @SethTisue","creator":{"login":"lrytz","id":119636,"node_id":"MDQ6VXNlcjExOTYzNg==","avatar_url":"https://avatars1.githubusercontent.com/u/119636?v=4","gravatar_id":"","url":"https://api.github.com/users/lrytz","html_url":"https://github.com/lrytz","followers_url":"https://api.github.com/users/lrytz/followers","following_url":"https://api.github.com/users/lrytz/following{/other_user}","gists_url":"https://api.github.com/users/lrytz/gists{/gist_id}","starred_url":"https://api.github.com/users/lrytz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lrytz/subscriptions","organizations_url":"https://api.github.com/users/lrytz/orgs","repos_url":"https://api.github.com/users/lrytz/repos","events_url":"https://api.github.com/users/lrytz/events{/privacy}","received_events_url":"https://api.github.com/users/lrytz/received_events","type":"User","site_admin":false},"open_issues":83,"closed_issues":217,"state":"open","created_at":"2018-04-25T07:15:17Z","updated_at":"2018-07-04T00:36:54Z","due_on":"2018-08-10T07:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/scala/scala/pulls/6878/commits","review_comments_url":"https://api.github.com/repos/scala/scala/pulls/6878/comments","review_comment_url":"https://api.github.com/repos/scala/scala/pulls/comments{/number}","comments_url":"https://api.github.com/repos/scala/scala/issues/6878/comments","statuses_url":"https://api.github.com/repos/scala/scala/statuses/76ec075f7022930bac9d9992a0b0a3050047c0b4","head":{"label":"isaacl:mkStringOpts","ref":"mkStringOpts","sha":"76ec075f7022930bac9d9992a0b0a3050047c0b4","user":{"login":"isaacl","id":1027886,"node_id":"MDQ6VXNlcjEwMjc4ODY=","avatar_url":"https://avatars2.githubusercontent.com/u/1027886?v=4","gravatar_id":"","url":"https://api.github.com/users/isaacl","html_url":"https://github.com/isaacl","followers_url":"https://api.github.com/users/isaacl/followers","following_url":"https://api.github.com/users/isaacl/following{/other_user}","gists_url":"https://api.github.com/users/isaacl/gists{/gist_id}","starred_url":"https://api.github.com/users/isaacl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isaacl/subscriptions","organizations_url":"https://api.github.com/users/isaacl/orgs","repos_url":"https://api.github.com/users/isaacl/repos","events_url":"https://api.github.com/users/isaacl/events{/privacy}","received_events_url":"https://api.github.com/users/isaacl/received_events","type":"User","site_admin":false},"repo":{"id":129915738,"node_id":"MDEwOlJlcG9zaXRvcnkxMjk5MTU3Mzg=","name":"scala","full_name":"isaacl/scala","owner":{"login":"isaacl","id":1027886,"node_id":"MDQ6VXNlcjEwMjc4ODY=","avatar_url":"https://avatars2.githubusercontent.com/u/1027886?v=4","gravatar_id":"","url":"https://api.github.com/users/isaacl","html_url":"https://github.com/isaacl","followers_url":"https://api.github.com/users/isaacl/followers","following_url":"https://api.github.com/users/isaacl/following{/other_user}","gists_url":"https://api.github.com/users/isaacl/gists{/gist_id}","starred_url":"https://api.github.com/users/isaacl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/isaacl/subscriptions","organizations_url":"https://api.github.com/users/isaacl/orgs","repos_url":"https://api.github.com/users/isaacl/repos","events_url":"https://api.github.com/users/isaacl/events{/privacy}","received_events_url":"https://api.github.com/users/isaacl/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/isaacl/scala","description":"The Scala programming language","fork":true,"url":"https://api.github.com/repos/isaacl/scala","forks_url":"https://api.github.com/repos/isaacl/scala/forks","keys_url":"https://api.github.com/repos/isaacl/scala/keys{/key_id}","collaborators_url":"https://api.github.com/repos/isaacl/scala/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/isaacl/scala/teams","hooks_url":"https://api.github.com/repos/isaacl/scala/hooks","issue_events_url":"https://api.github.com/repos/isaacl/scala/issues/events{/number}","events_url":"https://api.github.com/repos/isaacl/scala/events","assignees_url":"https://api.github.com/repos/isaacl/scala/assignees{/user}","branches_url":"https://api.github.com/repos/isaacl/scala/branches{/branch}","tags_url":"https://api.github.com/repos/isaacl/scala/tags","blobs_url":"https://api.github.com/repos/isaacl/scala/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/isaacl/scala/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/isaacl/scala/git/refs{/sha}","trees_url":"https://api.github.com/repos/isaacl/scala/git/trees{/sha}","statuses_url":"https://api.github.com/repos/isaacl/scala/statuses/{sha}","languages_url":"https://api.github.com/repos/isaacl/scala/languages","stargazers_url":"https://api.github.com/repos/isaacl/scala/stargazers","contributors_url":"https://api.github.com/repos/isaacl/scala/contributors","subscribers_url":"https://api.github.com/repos/isaacl/scala/subscribers","subscription_url":"https://api.github.com/repos/isaacl/scala/subscription","commits_url":"https://api.github.com/repos/isaacl/scala/commits{/sha}","git_commits_url":"https://api.github.com/repos/isaacl/scala/git/commits{/sha}","comments_url":"https://api.github.com/repos/isaacl/scala/comments{/number}","issue_comment_url":"https://api.github.com/repos/isaacl/scala/issues/comments{/number}","contents_url":"https://api.github.com/repos/isaacl/scala/contents/{+path}","compare_url":"https://api.github.com/repos/isaacl/scala/compare/{base}...{head}","merges_url":"https://api.github.com/repos/isaacl/scala/merges","archive_url":"https://api.github.com/repos/isaacl/scala/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/isaacl/scala/downloads","issues_url":"https://api.github.com/repos/isaacl/scala/issues{/number}","pulls_url":"https://api.github.com/repos/isaacl/scala/pulls{/number}","milestones_url":"https://api.github.com/repos/isaacl/scala/milestones{/number}","notifications_url":"https://api.github.com/repos/isaacl/scala/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/isaacl/scala/labels{/name}","releases_url":"https://api.github.com/repos/isaacl/scala/releases{/id}","deployments_url":"https://api.github.com/repos/isaacl/scala/deployments","created_at":"2018-04-17T14:18:13Z","updated_at":"2018-04-17T14:18:27Z","pushed_at":"2018-07-04T03:06:34Z","git_url":"git://github.com/isaacl/scala.git","ssh_url":"git@github.com:isaacl/scala.git","clone_url":"https://github.com/isaacl/scala.git","svn_url":"https://github.com/isaacl/scala","homepage":"http://www.scala-lang.org/","size":99568,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"2.13.x"}},"base":{"label":"scala:2.13.x","ref":"2.13.x","sha":"11d341b962ab5ed6e01a75b429ed7939d69d2e53","user":{"login":"scala","id":57059,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU3MDU5","avatar_url":"https://avatars2.githubusercontent.com/u/57059?v=4","gravatar_id":"","url":"https://api.github.com/users/scala","html_url":"https://github.com/scala","followers_url":"https://api.github.com/users/scala/followers","following_url":"https://api.github.com/users/scala/following{/other_user}","gists_url":"https://api.github.com/users/scala/gists{/gist_id}","starred_url":"https://api.github.com/users/scala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scala/subscriptions","organizations_url":"https://api.github.com/users/scala/orgs","repos_url":"https://api.github.com/users/scala/repos","events_url":"https://api.github.com/users/scala/events{/privacy}","received_events_url":"https://api.github.com/users/scala/received_events","type":"Organization","site_admin":false},"repo":{"id":2888818,"node_id":"MDEwOlJlcG9zaXRvcnkyODg4ODE4","name":"scala","full_name":"scala/scala","owner":{"login":"scala","id":57059,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU3MDU5","avatar_url":"https://avatars2.githubusercontent.com/u/57059?v=4","gravatar_id":"","url":"https://api.github.com/users/scala","html_url":"https://github.com/scala","followers_url":"https://api.github.com/users/scala/followers","following_url":"https://api.github.com/users/scala/following{/other_user}","gists_url":"https://api.github.com/users/scala/gists{/gist_id}","starred_url":"https://api.github.com/users/scala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scala/subscriptions","organizations_url":"https://api.github.com/users/scala/orgs","repos_url":"https://api.github.com/users/scala/repos","events_url":"https://api.github.com/users/scala/events{/privacy}","received_events_url":"https://api.github.com/users/scala/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/scala/scala","description":"The Scala programming language","fork":false,"url":"https://api.github.com/repos/scala/scala","forks_url":"https://api.github.com/repos/scala/scala/forks","keys_url":"https://api.github.com/repos/scala/scala/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scala/scala/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scala/scala/teams","hooks_url":"https://api.github.com/repos/scala/scala/hooks","issue_events_url":"https://api.github.com/repos/scala/scala/issues/events{/number}","events_url":"https://api.github.com/repos/scala/scala/events","assignees_url":"https://api.github.com/repos/scala/scala/assignees{/user}","branches_url":"https://api.github.com/repos/scala/scala/branches{/branch}","tags_url":"https://api.github.com/repos/scala/scala/tags","blobs_url":"https://api.github.com/repos/scala/scala/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scala/scala/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scala/scala/git/refs{/sha}","trees_url":"https://api.github.com/repos/scala/scala/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scala/scala/statuses/{sha}","languages_url":"https://api.github.com/repos/scala/scala/languages","stargazers_url":"https://api.github.com/repos/scala/scala/stargazers","contributors_url":"https://api.github.com/repos/scala/scala/contributors","subscribers_url":"https://api.github.com/repos/scala/scala/subscribers","subscription_url":"https://api.github.com/repos/scala/scala/subscription","commits_url":"https://api.github.com/repos/scala/scala/commits{/sha}","git_commits_url":"https://api.github.com/repos/scala/scala/git/commits{/sha}","comments_url":"https://api.github.com/repos/scala/scala/comments{/number}","issue_comment_url":"https://api.github.com/repos/scala/scala/issues/comments{/number}","contents_url":"https://api.github.com/repos/scala/scala/contents/{+path}","compare_url":"https://api.github.com/repos/scala/scala/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scala/scala/merges","archive_url":"https://api.github.com/repos/scala/scala/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scala/scala/downloads","issues_url":"https://api.github.com/repos/scala/scala/issues{/number}","pulls_url":"https://api.github.com/repos/scala/scala/pulls{/number}","milestones_url":"https://api.github.com/repos/scala/scala/milestones{/number}","notifications_url":"https://api.github.com/repos/scala/scala/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scala/scala/labels{/name}","releases_url":"https://api.github.com/repos/scala/scala/releases{/id}","deployments_url":"https://api.github.com/repos/scala/scala/deployments","created_at":"2011-12-01T05:02:34Z","updated_at":"2018-07-04T02:03:50Z","pushed_at":"2018-07-04T03:06:36Z","git_url":"git://github.com/scala/scala.git","ssh_url":"git@github.com:scala/scala.git","clone_url":"https://github.com/scala/scala.git","svn_url":"https://github.com/scala/scala","homepage":"http://www.scala-lang.org/","size":99630,"stargazers_count":10383,"watchers_count":10383,"language":"Scala","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":2466,"mirror_url":null,"archived":false,"open_issues_count":96,"license":{"key":"bsd-3-clause","name":"BSD 3-Clause \"New\" or \"Revised\" License","spdx_id":"BSD-3-Clause","url":"https://api.github.com/licenses/bsd-3-clause","node_id":"MDc6TGljZW5zZTU="},"forks":2466,"open_issues":96,"watchers":10383,"default_branch":"2.13.x"}},"_links":{"self":{"href":"https://api.github.com/repos/scala/scala/pulls/6878"},"html":{"href":"https://github.com/scala/scala/pull/6878"},"issue":{"href":"https://api.github.com/repos/scala/scala/issues/6878"},"comments":{"href":"https://api.github.com/repos/scala/scala/issues/6878/comments"},"review_comments":{"href":"https://api.github.com/repos/scala/scala/pulls/6878/comments"},"review_comment":{"href":"https://api.github.com/repos/scala/scala/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/scala/scala/pulls/6878/commits"},"statuses":{"href":"https://api.github.com/repos/scala/scala/statuses/76ec075f7022930bac9d9992a0b0a3050047c0b4"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"isaacl"}}