{"action":"created","comment":{"url":"https://api.github.com/repos/netty/netty/pulls/comments/114021987","pull_request_review_id":35464163,"id":114021987,"diff_hunk":"@@ -348,47 +332,47 @@ public static boolean isIpV6AddressesPreferred() {\n     }\n \n     private static int getIntValue(char c) {\n-        switch (c) {\n-            case '0':\n-                return 0;\n-            case '1':\n-                return 1;\n-            case '2':\n-                return 2;\n-            case '3':\n-                return 3;\n-            case '4':\n-                return 4;\n-            case '5':\n-                return 5;\n-            case '6':\n-                return 6;\n-            case '7':\n-                return 7;\n-            case '8':\n-                return 8;\n-            case '9':\n-                return 9;\n+        if (c >= '0' && c <= '9') {\n+            return c - '0';\n         }\n-\n-        c = Character.toLowerCase(c);\n-        switch (c) {\n-            case 'a':\n-                return 10;\n-            case 'b':\n-                return 11;\n-            case 'c':\n-                return 12;\n-            case 'd':\n-                return 13;\n-            case 'e':\n-                return 14;\n-            case 'f':\n-                return 15;\n+        if (c >= 'A' && c <= 'F') {\n+            return c - 'A' + 10;\n+        }\n+        if (c >= 'a' && c <= 'f') {\n+            return c - 'a' + 10;\n         }\n         return 0;\n     }\n \n+    private static int decimalDigit(String str, int pos) {\n+        return str.charAt(pos) - '0';\n+    }\n+\n+    private static byte ipv4WordToByte(String ip, int from, int to) {\n+        int ret = decimalDigit(ip, from);\n+        from++;\n+        if (from == to) {\n+            return (byte) ret;\n+        }\n+        ret = ret * 10 + decimalDigit(ip, from);\n+        from++;\n+        if (from == to) {\n+            return (byte) ret;\n+        }\n+        return (byte) (ret * 10 + decimalDigit(ip, from));\n+    }\n+\n+    // visible for tests\n+    static byte[] validIpV4ToBytes(String ip) {\n+        int i;\n+        return new byte[] {\n+                ipv4WordToByte(ip, 0, i = ip.indexOf('.', 1)),","path":"common/src/main/java/io/netty/util/NetUtil.java","position":113,"original_position":113,"commit_id":"e52f62416b31f42d36a787ad2a6195d02d593924","original_commit_id":"e52f62416b31f42d36a787ad2a6195d02d593924","user":{"login":"netkins","id":9507557,"avatar_url":"https://avatars0.githubusercontent.com/u/9507557?v=3","gravatar_id":"","url":"https://api.github.com/users/netkins","html_url":"https://github.com/netkins","followers_url":"https://api.github.com/users/netkins/followers","following_url":"https://api.github.com/users/netkins/following{/other_user}","gists_url":"https://api.github.com/users/netkins/gists{/gist_id}","starred_url":"https://api.github.com/users/netkins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netkins/subscriptions","organizations_url":"https://api.github.com/users/netkins/orgs","repos_url":"https://api.github.com/users/netkins/repos","events_url":"https://api.github.com/users/netkins/events{/privacy}","received_events_url":"https://api.github.com/users/netkins/received_events","type":"User","site_admin":false},"body":"![MAJOR](https://raw.githubusercontent.com/SonarCommunity/sonar-github/master/images/severity-major.png) Extract the assignment out of this expression. [![rule](https://raw.githubusercontent.com/SonarCommunity/sonar-github/master/images/rule.png)](https://garage.netty.io/sonarqube/coding_rules#rule_key=squid%3AAssignmentInSubExpressionCheck)\n![MAJOR](https://raw.githubusercontent.com/SonarCommunity/sonar-github/master/images/severity-major.png) Remove this useless assignment to local variable \"i\". [![rule](https://raw.githubusercontent.com/SonarCommunity/sonar-github/master/images/rule.png)](https://garage.netty.io/sonarqube/coding_rules#rule_key=squid%3AS1854)\n","created_at":"2017-04-28T21:20:28Z","updated_at":"2017-04-28T21:20:28Z","html_url":"https://github.com/netty/netty/pull/6493#discussion_r114021987","pull_request_url":"https://api.github.com/repos/netty/netty/pulls/6493","_links":{"self":{"href":"https://api.github.com/repos/netty/netty/pulls/comments/114021987"},"html":{"href":"https://github.com/netty/netty/pull/6493#discussion_r114021987"},"pull_request":{"href":"https://api.github.com/repos/netty/netty/pulls/6493"}}},"pull_request":{"url":"https://api.github.com/repos/netty/netty/pulls/6493","id":109113414,"html_url":"https://github.com/netty/netty/pull/6493","diff_url":"https://github.com/netty/netty/pull/6493.diff","patch_url":"https://github.com/netty/netty/pull/6493.patch","issue_url":"https://api.github.com/repos/netty/netty/issues/6493","number":6493,"state":"open","locked":false,"title":"Optimizations in NetUtil","user":{"login":"fenik17","id":20779569,"avatar_url":"https://avatars0.githubusercontent.com/u/20779569?v=3","gravatar_id":"","url":"https://api.github.com/users/fenik17","html_url":"https://github.com/fenik17","followers_url":"https://api.github.com/users/fenik17/followers","following_url":"https://api.github.com/users/fenik17/following{/other_user}","gists_url":"https://api.github.com/users/fenik17/gists{/gist_id}","starred_url":"https://api.github.com/users/fenik17/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fenik17/subscriptions","organizations_url":"https://api.github.com/users/fenik17/orgs","repos_url":"https://api.github.com/users/fenik17/repos","events_url":"https://api.github.com/users/fenik17/events{/privacy}","received_events_url":"https://api.github.com/users/fenik17/received_events","type":"User","site_admin":false},"body":"Motivation:\r\n\r\nIPv4/6 validation methods use allocations, which can be avoided.\r\nIPv4 parse method use StringTokenizer.\r\n\r\nModifications:\r\n\r\nRewriting IPv4/6 validation methods to avoid allocations.\r\nRewriting IPv4 parse method without use StringTokenizer.\r\n\r\nResult:\r\n\r\nIPv4/6 validation and IPv4 parsing faster up to 2-10x.","created_at":"2017-03-04T16:36:58Z","updated_at":"2017-04-28T21:20:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"81c40bad2f2bbf3a4b03060563818a9fa606e311","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/netty/netty/pulls/6493/commits","review_comments_url":"https://api.github.com/repos/netty/netty/pulls/6493/comments","review_comment_url":"https://api.github.com/repos/netty/netty/pulls/comments{/number}","comments_url":"https://api.github.com/repos/netty/netty/issues/6493/comments","statuses_url":"https://api.github.com/repos/netty/netty/statuses/e52f62416b31f42d36a787ad2a6195d02d593924","head":{"label":"fenik17:net_util_optimizations","ref":"net_util_optimizations","sha":"e52f62416b31f42d36a787ad2a6195d02d593924","user":{"login":"fenik17","id":20779569,"avatar_url":"https://avatars0.githubusercontent.com/u/20779569?v=3","gravatar_id":"","url":"https://api.github.com/users/fenik17","html_url":"https://github.com/fenik17","followers_url":"https://api.github.com/users/fenik17/followers","following_url":"https://api.github.com/users/fenik17/following{/other_user}","gists_url":"https://api.github.com/users/fenik17/gists{/gist_id}","starred_url":"https://api.github.com/users/fenik17/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fenik17/subscriptions","organizations_url":"https://api.github.com/users/fenik17/orgs","repos_url":"https://api.github.com/users/fenik17/repos","events_url":"https://api.github.com/users/fenik17/events{/privacy}","received_events_url":"https://api.github.com/users/fenik17/received_events","type":"User","site_admin":false},"repo":{"id":82708489,"name":"netty","full_name":"fenik17/netty","owner":{"login":"fenik17","id":20779569,"avatar_url":"https://avatars0.githubusercontent.com/u/20779569?v=3","gravatar_id":"","url":"https://api.github.com/users/fenik17","html_url":"https://github.com/fenik17","followers_url":"https://api.github.com/users/fenik17/followers","following_url":"https://api.github.com/users/fenik17/following{/other_user}","gists_url":"https://api.github.com/users/fenik17/gists{/gist_id}","starred_url":"https://api.github.com/users/fenik17/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fenik17/subscriptions","organizations_url":"https://api.github.com/users/fenik17/orgs","repos_url":"https://api.github.com/users/fenik17/repos","events_url":"https://api.github.com/users/fenik17/events{/privacy}","received_events_url":"https://api.github.com/users/fenik17/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fenik17/netty","description":"Netty project - an event-driven asynchronous network application framework","fork":true,"url":"https://api.github.com/repos/fenik17/netty","forks_url":"https://api.github.com/repos/fenik17/netty/forks","keys_url":"https://api.github.com/repos/fenik17/netty/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fenik17/netty/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fenik17/netty/teams","hooks_url":"https://api.github.com/repos/fenik17/netty/hooks","issue_events_url":"https://api.github.com/repos/fenik17/netty/issues/events{/number}","events_url":"https://api.github.com/repos/fenik17/netty/events","assignees_url":"https://api.github.com/repos/fenik17/netty/assignees{/user}","branches_url":"https://api.github.com/repos/fenik17/netty/branches{/branch}","tags_url":"https://api.github.com/repos/fenik17/netty/tags","blobs_url":"https://api.github.com/repos/fenik17/netty/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fenik17/netty/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fenik17/netty/git/refs{/sha}","trees_url":"https://api.github.com/repos/fenik17/netty/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fenik17/netty/statuses/{sha}","languages_url":"https://api.github.com/repos/fenik17/netty/languages","stargazers_url":"https://api.github.com/repos/fenik17/netty/stargazers","contributors_url":"https://api.github.com/repos/fenik17/netty/contributors","subscribers_url":"https://api.github.com/repos/fenik17/netty/subscribers","subscription_url":"https://api.github.com/repos/fenik17/netty/subscription","commits_url":"https://api.github.com/repos/fenik17/netty/commits{/sha}","git_commits_url":"https://api.github.com/repos/fenik17/netty/git/commits{/sha}","comments_url":"https://api.github.com/repos/fenik17/netty/comments{/number}","issue_comment_url":"https://api.github.com/repos/fenik17/netty/issues/comments{/number}","contents_url":"https://api.github.com/repos/fenik17/netty/contents/{+path}","compare_url":"https://api.github.com/repos/fenik17/netty/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fenik17/netty/merges","archive_url":"https://api.github.com/repos/fenik17/netty/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fenik17/netty/downloads","issues_url":"https://api.github.com/repos/fenik17/netty/issues{/number}","pulls_url":"https://api.github.com/repos/fenik17/netty/pulls{/number}","milestones_url":"https://api.github.com/repos/fenik17/netty/milestones{/number}","notifications_url":"https://api.github.com/repos/fenik17/netty/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fenik17/netty/labels{/name}","releases_url":"https://api.github.com/repos/fenik17/netty/releases{/id}","deployments_url":"https://api.github.com/repos/fenik17/netty/deployments","created_at":"2017-02-21T17:37:03Z","updated_at":"2017-02-21T17:37:16Z","pushed_at":"2017-04-28T20:12:00Z","git_url":"git://github.com/fenik17/netty.git","ssh_url":"git@github.com:fenik17/netty.git","clone_url":"https://github.com/fenik17/netty.git","svn_url":"https://github.com/fenik17/netty","homepage":"http://netty.io/","size":45984,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"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":"4.1"}},"base":{"label":"netty:4.1","ref":"4.1","sha":"3ba4da8a79acfdbe6daf35da96f5a0bf36fb9fe4","user":{"login":"netty","id":473791,"avatar_url":"https://avatars2.githubusercontent.com/u/473791?v=3","gravatar_id":"","url":"https://api.github.com/users/netty","html_url":"https://github.com/netty","followers_url":"https://api.github.com/users/netty/followers","following_url":"https://api.github.com/users/netty/following{/other_user}","gists_url":"https://api.github.com/users/netty/gists{/gist_id}","starred_url":"https://api.github.com/users/netty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netty/subscriptions","organizations_url":"https://api.github.com/users/netty/orgs","repos_url":"https://api.github.com/users/netty/repos","events_url":"https://api.github.com/users/netty/events{/privacy}","received_events_url":"https://api.github.com/users/netty/received_events","type":"Organization","site_admin":false},"repo":{"id":1064563,"name":"netty","full_name":"netty/netty","owner":{"login":"netty","id":473791,"avatar_url":"https://avatars2.githubusercontent.com/u/473791?v=3","gravatar_id":"","url":"https://api.github.com/users/netty","html_url":"https://github.com/netty","followers_url":"https://api.github.com/users/netty/followers","following_url":"https://api.github.com/users/netty/following{/other_user}","gists_url":"https://api.github.com/users/netty/gists{/gist_id}","starred_url":"https://api.github.com/users/netty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/netty/subscriptions","organizations_url":"https://api.github.com/users/netty/orgs","repos_url":"https://api.github.com/users/netty/repos","events_url":"https://api.github.com/users/netty/events{/privacy}","received_events_url":"https://api.github.com/users/netty/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/netty/netty","description":"Netty project - an event-driven asynchronous network application framework","fork":false,"url":"https://api.github.com/repos/netty/netty","forks_url":"https://api.github.com/repos/netty/netty/forks","keys_url":"https://api.github.com/repos/netty/netty/keys{/key_id}","collaborators_url":"https://api.github.com/repos/netty/netty/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/netty/netty/teams","hooks_url":"https://api.github.com/repos/netty/netty/hooks","issue_events_url":"https://api.github.com/repos/netty/netty/issues/events{/number}","events_url":"https://api.github.com/repos/netty/netty/events","assignees_url":"https://api.github.com/repos/netty/netty/assignees{/user}","branches_url":"https://api.github.com/repos/netty/netty/branches{/branch}","tags_url":"https://api.github.com/repos/netty/netty/tags","blobs_url":"https://api.github.com/repos/netty/netty/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/netty/netty/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/netty/netty/git/refs{/sha}","trees_url":"https://api.github.com/repos/netty/netty/git/trees{/sha}","statuses_url":"https://api.github.com/repos/netty/netty/statuses/{sha}","languages_url":"https://api.github.com/repos/netty/netty/languages","stargazers_url":"https://api.github.com/repos/netty/netty/stargazers","contributors_url":"https://api.github.com/repos/netty/netty/contributors","subscribers_url":"https://api.github.com/repos/netty/netty/subscribers","subscription_url":"https://api.github.com/repos/netty/netty/subscription","commits_url":"https://api.github.com/repos/netty/netty/commits{/sha}","git_commits_url":"https://api.github.com/repos/netty/netty/git/commits{/sha}","comments_url":"https://api.github.com/repos/netty/netty/comments{/number}","issue_comment_url":"https://api.github.com/repos/netty/netty/issues/comments{/number}","contents_url":"https://api.github.com/repos/netty/netty/contents/{+path}","compare_url":"https://api.github.com/repos/netty/netty/compare/{base}...{head}","merges_url":"https://api.github.com/repos/netty/netty/merges","archive_url":"https://api.github.com/repos/netty/netty/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/netty/netty/downloads","issues_url":"https://api.github.com/repos/netty/netty/issues{/number}","pulls_url":"https://api.github.com/repos/netty/netty/pulls{/number}","milestones_url":"https://api.github.com/repos/netty/netty/milestones{/number}","notifications_url":"https://api.github.com/repos/netty/netty/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/netty/netty/labels{/name}","releases_url":"https://api.github.com/repos/netty/netty/releases{/id}","deployments_url":"https://api.github.com/repos/netty/netty/deployments","created_at":"2010-11-09T09:22:21Z","updated_at":"2017-04-28T20:59:18Z","pushed_at":"2017-04-28T20:12:02Z","git_url":"git://github.com/netty/netty.git","ssh_url":"git@github.com:netty/netty.git","clone_url":"https://github.com/netty/netty.git","svn_url":"https://github.com/netty/netty","homepage":"http://netty.io/","size":46750,"stargazers_count":9812,"watchers_count":9812,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4792,"mirror_url":null,"open_issues_count":358,"forks":4792,"open_issues":358,"watchers":9812,"default_branch":"4.1"}},"_links":{"self":{"href":"https://api.github.com/repos/netty/netty/pulls/6493"},"html":{"href":"https://github.com/netty/netty/pull/6493"},"issue":{"href":"https://api.github.com/repos/netty/netty/issues/6493"},"comments":{"href":"https://api.github.com/repos/netty/netty/issues/6493/comments"},"review_comments":{"href":"https://api.github.com/repos/netty/netty/pulls/6493/comments"},"review_comment":{"href":"https://api.github.com/repos/netty/netty/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/netty/netty/pulls/6493/commits"},"statuses":{"href":"https://api.github.com/repos/netty/netty/statuses/e52f62416b31f42d36a787ad2a6195d02d593924"}}}}
{"actor":{"display_login":"netkins"}}