{"action":"created","comment":{"url":"https://api.github.com/repos/akka/akka/pulls/comments/76075993","id":76075993,"diff_hunk":"@@ -253,9 +253,11 @@ object ByteString {\n       else ByteString1(bytes, startIndex, Math.min(n, length))\n \n     override def slice(from: Int, until: Int): ByteString = {","path":"akka-actor/src/main/scala/akka/util/ByteString.scala","position":14,"original_position":14,"commit_id":"ea4ff374adf66a4ce51f6ee2b45313549f8f33c2","original_commit_id":"ea4ff374adf66a4ce51f6ee2b45313549f8f33c2","user":{"login":"ktoso","id":120979,"avatar_url":"https://avatars.githubusercontent.com/u/120979?v=3","gravatar_id":"","url":"https://api.github.com/users/ktoso","html_url":"https://github.com/ktoso","followers_url":"https://api.github.com/users/ktoso/followers","following_url":"https://api.github.com/users/ktoso/following{/other_user}","gists_url":"https://api.github.com/users/ktoso/gists{/gist_id}","starred_url":"https://api.github.com/users/ktoso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ktoso/subscriptions","organizations_url":"https://api.github.com/users/ktoso/orgs","repos_url":"https://api.github.com/users/ktoso/repos","events_url":"https://api.github.com/users/ktoso/events{/privacy}","received_events_url":"https://api.github.com/users/ktoso/received_events","type":"User","site_admin":false},"body":"Meh still optimising the above...","created_at":"2016-08-24T15:12:03Z","updated_at":"2016-08-24T15:12:03Z","html_url":"https://github.com/akka/akka/pull/21248#discussion_r76075993","pull_request_url":"https://api.github.com/repos/akka/akka/pulls/21248","_links":{"self":{"href":"https://api.github.com/repos/akka/akka/pulls/comments/76075993"},"html":{"href":"https://github.com/akka/akka/pull/21248#discussion_r76075993"},"pull_request":{"href":"https://api.github.com/repos/akka/akka/pulls/21248"}}},"pull_request":{"url":"https://api.github.com/repos/akka/akka/pulls/21248","id":82227559,"html_url":"https://github.com/akka/akka/pull/21248","diff_url":"https://github.com/akka/akka/pull/21248.diff","patch_url":"https://github.com/akka/akka/pull/21248.patch","issue_url":"https://api.github.com/repos/akka/akka/issues/21248","number":21248,"state":"open","locked":false,"title":"=Fix regression of akka.util.ByteString#slice(...)","user":{"login":"monkey-mas","id":5261677,"avatar_url":"https://avatars.githubusercontent.com/u/5261677?v=3","gravatar_id":"","url":"https://api.github.com/users/monkey-mas","html_url":"https://github.com/monkey-mas","followers_url":"https://api.github.com/users/monkey-mas/followers","following_url":"https://api.github.com/users/monkey-mas/following{/other_user}","gists_url":"https://api.github.com/users/monkey-mas/gists{/gist_id}","starred_url":"https://api.github.com/users/monkey-mas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monkey-mas/subscriptions","organizations_url":"https://api.github.com/users/monkey-mas/orgs","repos_url":"https://api.github.com/users/monkey-mas/repos","events_url":"https://api.github.com/users/monkey-mas/events{/privacy}","received_events_url":"https://api.github.com/users/monkey-mas/received_events","type":"User","site_admin":false},"body":"Fixes #21237\r\n\r\nCurrently slice(...) method unexpectedly throws an error for some arguments. The issue comes from a corner-case of string _slice_ and we can fix this by correctly handling 6 basic patterns(scenarios) described as follows:\r\n\r\nSuppose the two input arguments are;\r\n1) from, until <= 0\r\nWe check if `until <= 0` is met and return `ByteString.empty` if this is the case.\r\n\r\n2) length <= from, until\r\nWe check if `length <= from` is met and return `ByteString.empty` if this is the case.\r\n\r\n3) from <= 0 && length <= until\r\nWe return the byte string itself as we can _compact_ it.\r\n\r\n4) 0 <= from <= until <= length\r\nWe _slice_ the byte string starting from `from` with the length of `until - from`\r\n\r\n5) from < 0\r\nBased on the condition 1, 2, 3 and 4, we know that there're two cases left, i.e., either `from` or `until` is out of the _valid_ range, as we've checked a) both of them are in the valid range in 4 and b) neither of them is in the valid range (or we don't have to actually slice it where `from == 0` and `until == length`) in 3. If `from` is the one that is out of the valid range then `0 <= until <= length` is satisfied, which means we can return _slice_ from `0` to `until`.\r\n\r\n6) length < until\r\nVice versa, if `until` is the one out of the valid range then `0 <= from <= length` is true, which indicates we can return _slice_ from `from` to `length` with the length of `length - from`.\r\n\r\nTo satisfy the condition 4, 5 and 6, we need to check if `from <= until` is met. To do this, ByteString1#slice(...) has the corresponding logic.\r\n\r\nP.S.\r\nI might misunderstand how the slice methods in `ByteString` and `ByteString1` should work, also this change might deteriorate the performance optimization of `slice`. If this is the case, please let me know. I'll do my best to fix my changes again :)","created_at":"2016-08-22T17:07:40Z","updated_at":"2016-08-24T15:12:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"85ed0136b96d7236748438ad2fb25cf383d867e7","assignee":{"login":"ktoso","id":120979,"avatar_url":"https://avatars.githubusercontent.com/u/120979?v=3","gravatar_id":"","url":"https://api.github.com/users/ktoso","html_url":"https://github.com/ktoso","followers_url":"https://api.github.com/users/ktoso/followers","following_url":"https://api.github.com/users/ktoso/following{/other_user}","gists_url":"https://api.github.com/users/ktoso/gists{/gist_id}","starred_url":"https://api.github.com/users/ktoso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ktoso/subscriptions","organizations_url":"https://api.github.com/users/ktoso/orgs","repos_url":"https://api.github.com/users/ktoso/repos","events_url":"https://api.github.com/users/ktoso/events{/privacy}","received_events_url":"https://api.github.com/users/ktoso/received_events","type":"User","site_admin":false},"assignees":[{"login":"ktoso","id":120979,"avatar_url":"https://avatars.githubusercontent.com/u/120979?v=3","gravatar_id":"","url":"https://api.github.com/users/ktoso","html_url":"https://github.com/ktoso","followers_url":"https://api.github.com/users/ktoso/followers","following_url":"https://api.github.com/users/ktoso/following{/other_user}","gists_url":"https://api.github.com/users/ktoso/gists{/gist_id}","starred_url":"https://api.github.com/users/ktoso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ktoso/subscriptions","organizations_url":"https://api.github.com/users/ktoso/orgs","repos_url":"https://api.github.com/users/ktoso/repos","events_url":"https://api.github.com/users/ktoso/events{/privacy}","received_events_url":"https://api.github.com/users/ktoso/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/akka/akka/pulls/21248/commits","review_comments_url":"https://api.github.com/repos/akka/akka/pulls/21248/comments","review_comment_url":"https://api.github.com/repos/akka/akka/pulls/comments{/number}","comments_url":"https://api.github.com/repos/akka/akka/issues/21248/comments","statuses_url":"https://api.github.com/repos/akka/akka/statuses/ea4ff374adf66a4ce51f6ee2b45313549f8f33c2","head":{"label":"monkey-mas:fix-regression-of-byte-string","ref":"fix-regression-of-byte-string","sha":"ea4ff374adf66a4ce51f6ee2b45313549f8f33c2","user":{"login":"monkey-mas","id":5261677,"avatar_url":"https://avatars.githubusercontent.com/u/5261677?v=3","gravatar_id":"","url":"https://api.github.com/users/monkey-mas","html_url":"https://github.com/monkey-mas","followers_url":"https://api.github.com/users/monkey-mas/followers","following_url":"https://api.github.com/users/monkey-mas/following{/other_user}","gists_url":"https://api.github.com/users/monkey-mas/gists{/gist_id}","starred_url":"https://api.github.com/users/monkey-mas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monkey-mas/subscriptions","organizations_url":"https://api.github.com/users/monkey-mas/orgs","repos_url":"https://api.github.com/users/monkey-mas/repos","events_url":"https://api.github.com/users/monkey-mas/events{/privacy}","received_events_url":"https://api.github.com/users/monkey-mas/received_events","type":"User","site_admin":false},"repo":{"id":60627393,"name":"akka","full_name":"monkey-mas/akka","owner":{"login":"monkey-mas","id":5261677,"avatar_url":"https://avatars.githubusercontent.com/u/5261677?v=3","gravatar_id":"","url":"https://api.github.com/users/monkey-mas","html_url":"https://github.com/monkey-mas","followers_url":"https://api.github.com/users/monkey-mas/followers","following_url":"https://api.github.com/users/monkey-mas/following{/other_user}","gists_url":"https://api.github.com/users/monkey-mas/gists{/gist_id}","starred_url":"https://api.github.com/users/monkey-mas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monkey-mas/subscriptions","organizations_url":"https://api.github.com/users/monkey-mas/orgs","repos_url":"https://api.github.com/users/monkey-mas/repos","events_url":"https://api.github.com/users/monkey-mas/events{/privacy}","received_events_url":"https://api.github.com/users/monkey-mas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/monkey-mas/akka","description":"Akka Project","fork":true,"url":"https://api.github.com/repos/monkey-mas/akka","forks_url":"https://api.github.com/repos/monkey-mas/akka/forks","keys_url":"https://api.github.com/repos/monkey-mas/akka/keys{/key_id}","collaborators_url":"https://api.github.com/repos/monkey-mas/akka/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/monkey-mas/akka/teams","hooks_url":"https://api.github.com/repos/monkey-mas/akka/hooks","issue_events_url":"https://api.github.com/repos/monkey-mas/akka/issues/events{/number}","events_url":"https://api.github.com/repos/monkey-mas/akka/events","assignees_url":"https://api.github.com/repos/monkey-mas/akka/assignees{/user}","branches_url":"https://api.github.com/repos/monkey-mas/akka/branches{/branch}","tags_url":"https://api.github.com/repos/monkey-mas/akka/tags","blobs_url":"https://api.github.com/repos/monkey-mas/akka/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/monkey-mas/akka/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/monkey-mas/akka/git/refs{/sha}","trees_url":"https://api.github.com/repos/monkey-mas/akka/git/trees{/sha}","statuses_url":"https://api.github.com/repos/monkey-mas/akka/statuses/{sha}","languages_url":"https://api.github.com/repos/monkey-mas/akka/languages","stargazers_url":"https://api.github.com/repos/monkey-mas/akka/stargazers","contributors_url":"https://api.github.com/repos/monkey-mas/akka/contributors","subscribers_url":"https://api.github.com/repos/monkey-mas/akka/subscribers","subscription_url":"https://api.github.com/repos/monkey-mas/akka/subscription","commits_url":"https://api.github.com/repos/monkey-mas/akka/commits{/sha}","git_commits_url":"https://api.github.com/repos/monkey-mas/akka/git/commits{/sha}","comments_url":"https://api.github.com/repos/monkey-mas/akka/comments{/number}","issue_comment_url":"https://api.github.com/repos/monkey-mas/akka/issues/comments{/number}","contents_url":"https://api.github.com/repos/monkey-mas/akka/contents/{+path}","compare_url":"https://api.github.com/repos/monkey-mas/akka/compare/{base}...{head}","merges_url":"https://api.github.com/repos/monkey-mas/akka/merges","archive_url":"https://api.github.com/repos/monkey-mas/akka/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/monkey-mas/akka/downloads","issues_url":"https://api.github.com/repos/monkey-mas/akka/issues{/number}","pulls_url":"https://api.github.com/repos/monkey-mas/akka/pulls{/number}","milestones_url":"https://api.github.com/repos/monkey-mas/akka/milestones{/number}","notifications_url":"https://api.github.com/repos/monkey-mas/akka/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/monkey-mas/akka/labels{/name}","releases_url":"https://api.github.com/repos/monkey-mas/akka/releases{/id}","deployments_url":"https://api.github.com/repos/monkey-mas/akka/deployments","created_at":"2016-06-07T16:04:30Z","updated_at":"2016-06-07T16:04:43Z","pushed_at":"2016-08-22T17:10:30Z","git_url":"git://github.com/monkey-mas/akka.git","ssh_url":"git@github.com:monkey-mas/akka.git","clone_url":"https://github.com/monkey-mas/akka.git","svn_url":"https://github.com/monkey-mas/akka","homepage":"http://akka.io","size":188766,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"akka:master","ref":"master","sha":"caa98c0110f3c8ceb7383e745707ed6820841aeb","user":{"login":"akka","id":1496237,"avatar_url":"https://avatars.githubusercontent.com/u/1496237?v=3","gravatar_id":"","url":"https://api.github.com/users/akka","html_url":"https://github.com/akka","followers_url":"https://api.github.com/users/akka/followers","following_url":"https://api.github.com/users/akka/following{/other_user}","gists_url":"https://api.github.com/users/akka/gists{/gist_id}","starred_url":"https://api.github.com/users/akka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akka/subscriptions","organizations_url":"https://api.github.com/users/akka/orgs","repos_url":"https://api.github.com/users/akka/repos","events_url":"https://api.github.com/users/akka/events{/privacy}","received_events_url":"https://api.github.com/users/akka/received_events","type":"Organization","site_admin":false},"repo":{"id":130013,"name":"akka","full_name":"akka/akka","owner":{"login":"akka","id":1496237,"avatar_url":"https://avatars.githubusercontent.com/u/1496237?v=3","gravatar_id":"","url":"https://api.github.com/users/akka","html_url":"https://github.com/akka","followers_url":"https://api.github.com/users/akka/followers","following_url":"https://api.github.com/users/akka/following{/other_user}","gists_url":"https://api.github.com/users/akka/gists{/gist_id}","starred_url":"https://api.github.com/users/akka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akka/subscriptions","organizations_url":"https://api.github.com/users/akka/orgs","repos_url":"https://api.github.com/users/akka/repos","events_url":"https://api.github.com/users/akka/events{/privacy}","received_events_url":"https://api.github.com/users/akka/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/akka/akka","description":"Akka Project","fork":false,"url":"https://api.github.com/repos/akka/akka","forks_url":"https://api.github.com/repos/akka/akka/forks","keys_url":"https://api.github.com/repos/akka/akka/keys{/key_id}","collaborators_url":"https://api.github.com/repos/akka/akka/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/akka/akka/teams","hooks_url":"https://api.github.com/repos/akka/akka/hooks","issue_events_url":"https://api.github.com/repos/akka/akka/issues/events{/number}","events_url":"https://api.github.com/repos/akka/akka/events","assignees_url":"https://api.github.com/repos/akka/akka/assignees{/user}","branches_url":"https://api.github.com/repos/akka/akka/branches{/branch}","tags_url":"https://api.github.com/repos/akka/akka/tags","blobs_url":"https://api.github.com/repos/akka/akka/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/akka/akka/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/akka/akka/git/refs{/sha}","trees_url":"https://api.github.com/repos/akka/akka/git/trees{/sha}","statuses_url":"https://api.github.com/repos/akka/akka/statuses/{sha}","languages_url":"https://api.github.com/repos/akka/akka/languages","stargazers_url":"https://api.github.com/repos/akka/akka/stargazers","contributors_url":"https://api.github.com/repos/akka/akka/contributors","subscribers_url":"https://api.github.com/repos/akka/akka/subscribers","subscription_url":"https://api.github.com/repos/akka/akka/subscription","commits_url":"https://api.github.com/repos/akka/akka/commits{/sha}","git_commits_url":"https://api.github.com/repos/akka/akka/git/commits{/sha}","comments_url":"https://api.github.com/repos/akka/akka/comments{/number}","issue_comment_url":"https://api.github.com/repos/akka/akka/issues/comments{/number}","contents_url":"https://api.github.com/repos/akka/akka/contents/{+path}","compare_url":"https://api.github.com/repos/akka/akka/compare/{base}...{head}","merges_url":"https://api.github.com/repos/akka/akka/merges","archive_url":"https://api.github.com/repos/akka/akka/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/akka/akka/downloads","issues_url":"https://api.github.com/repos/akka/akka/issues{/number}","pulls_url":"https://api.github.com/repos/akka/akka/pulls{/number}","milestones_url":"https://api.github.com/repos/akka/akka/milestones{/number}","notifications_url":"https://api.github.com/repos/akka/akka/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/akka/akka/labels{/name}","releases_url":"https://api.github.com/repos/akka/akka/releases{/id}","deployments_url":"https://api.github.com/repos/akka/akka/deployments","created_at":"2009-02-16T12:51:54Z","updated_at":"2016-08-24T14:06:00Z","pushed_at":"2016-08-24T14:54:49Z","git_url":"git://github.com/akka/akka.git","ssh_url":"git@github.com:akka/akka.git","clone_url":"https://github.com/akka/akka.git","svn_url":"https://github.com/akka/akka","homepage":"http://akka.io","size":227943,"stargazers_count":5929,"watchers_count":5929,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1885,"mirror_url":null,"open_issues_count":717,"forks":1885,"open_issues":717,"watchers":5929,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/akka/akka/pulls/21248"},"html":{"href":"https://github.com/akka/akka/pull/21248"},"issue":{"href":"https://api.github.com/repos/akka/akka/issues/21248"},"comments":{"href":"https://api.github.com/repos/akka/akka/issues/21248/comments"},"review_comments":{"href":"https://api.github.com/repos/akka/akka/pulls/21248/comments"},"review_comment":{"href":"https://api.github.com/repos/akka/akka/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/akka/akka/pulls/21248/commits"},"statuses":{"href":"https://api.github.com/repos/akka/akka/statuses/ea4ff374adf66a4ce51f6ee2b45313549f8f33c2"}}}}
{"actor":{"display_login":"ktoso"}}