{"action":"opened","number":791,"pull_request":{"url":"https://api.github.com/repos/resteasy/Resteasy/pulls/791","id":69225443,"html_url":"https://github.com/resteasy/Resteasy/pull/791","diff_url":"https://github.com/resteasy/Resteasy/pull/791.diff","patch_url":"https://github.com/resteasy/Resteasy/pull/791.patch","issue_url":"https://api.github.com/repos/resteasy/Resteasy/issues/791","number":791,"state":"open","locked":false,"title":"[Resteasy-1197]: Performance Issue: org.jboss.resteasy.spi.ResteasyUriInfo instantiation takes 20% of all the CPU time","user":{"login":"NicoNes","id":19169964,"avatar_url":"https://avatars.githubusercontent.com/u/19169964?v=3","gravatar_id":"","url":"https://api.github.com/users/NicoNes","html_url":"https://github.com/NicoNes","followers_url":"https://api.github.com/users/NicoNes/followers","following_url":"https://api.github.com/users/NicoNes/following{/other_user}","gists_url":"https://api.github.com/users/NicoNes/gists{/gist_id}","starred_url":"https://api.github.com/users/NicoNes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NicoNes/subscriptions","organizations_url":"https://api.github.com/users/NicoNes/orgs","repos_url":"https://api.github.com/users/NicoNes/repos","events_url":"https://api.github.com/users/NicoNes/events{/privacy}","received_events_url":"https://api.github.com/users/NicoNes/received_events","type":"User","site_admin":false},"body":"The goal of this this pull request is to improve ResteasyUriBuilder performance by doing to things:\r\n\r\n- Replace all StringBuffer instances by StringBuilder. Because of thread safety, StringBuffer instances are a bit slower than StringBuilder. The massive use of StringBuffer was enforced by the use of java.util.regex.Matcher.appendReplacement(...) and java.util.regex.Matcher.appendTail(...) methods.\r\nThe idea is to keep on using java.util.regex.Matcher but stop calling those methods. To do so lets replace this pattern:\r\n\r\n> \t\tString templateString = ...;\r\n\t  Matcher matcher = Pattern.compile(...).matcher(templateString);\r\n\t  StringBuffer stringBuffer = new StringBuffer();\r\n\t  while (matcher.find()) {\r\n\t\t String matchedValue = matcher.group(1);\r\n\t\t String replacementString = ....;\r\n\t\t matcher.appendReplacement(stringBuffer, replacementString);\r\n\t }\r\n\t matcher.appendTail(stringBuffer);\r\n\t return stringBuffer.toString();\r\n\r\nBy this one:\r\n\r\n> \t  String templateString = ...;\r\n\t Matcher matcher = Pattern.compile(...).matcher(templateString);\r\n\t StringBuilder stringBuilder = new StringBuilder();\r\n\t int start = 0;\r\n\t while (matcher.find()) {\r\n\t\t stringBuilder.append(templateString, start, matcher.start());\r\n\t\t String matchedValue = matcher.group(1);\r\n\t\t String replacementString = ...;\r\n\t\t stringBuilder.append(replacementString);\r\n\t\t start = matcher.end();\r\n\t }\r\n\t stringBuilder.append(templateString, start, templateString.length());\r\n\t return stringBuilder.toString();","created_at":"2016-05-06T23:59:26Z","updated_at":"2016-05-06T23:59:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/resteasy/Resteasy/pulls/791/commits","review_comments_url":"https://api.github.com/repos/resteasy/Resteasy/pulls/791/comments","review_comment_url":"https://api.github.com/repos/resteasy/Resteasy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/resteasy/Resteasy/issues/791/comments","statuses_url":"https://api.github.com/repos/resteasy/Resteasy/statuses/9bdc0f922a913bde4f64ac059d4533cadd68b30c","head":{"label":"NicoNes:RESTEASY-1197","ref":"RESTEASY-1197","sha":"9bdc0f922a913bde4f64ac059d4533cadd68b30c","user":{"login":"NicoNes","id":19169964,"avatar_url":"https://avatars.githubusercontent.com/u/19169964?v=3","gravatar_id":"","url":"https://api.github.com/users/NicoNes","html_url":"https://github.com/NicoNes","followers_url":"https://api.github.com/users/NicoNes/followers","following_url":"https://api.github.com/users/NicoNes/following{/other_user}","gists_url":"https://api.github.com/users/NicoNes/gists{/gist_id}","starred_url":"https://api.github.com/users/NicoNes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NicoNes/subscriptions","organizations_url":"https://api.github.com/users/NicoNes/orgs","repos_url":"https://api.github.com/users/NicoNes/repos","events_url":"https://api.github.com/users/NicoNes/events{/privacy}","received_events_url":"https://api.github.com/users/NicoNes/received_events","type":"User","site_admin":false},"repo":{"id":58200658,"name":"Resteasy","full_name":"NicoNes/Resteasy","owner":{"login":"NicoNes","id":19169964,"avatar_url":"https://avatars.githubusercontent.com/u/19169964?v=3","gravatar_id":"","url":"https://api.github.com/users/NicoNes","html_url":"https://github.com/NicoNes","followers_url":"https://api.github.com/users/NicoNes/followers","following_url":"https://api.github.com/users/NicoNes/following{/other_user}","gists_url":"https://api.github.com/users/NicoNes/gists{/gist_id}","starred_url":"https://api.github.com/users/NicoNes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NicoNes/subscriptions","organizations_url":"https://api.github.com/users/NicoNes/orgs","repos_url":"https://api.github.com/users/NicoNes/repos","events_url":"https://api.github.com/users/NicoNes/events{/privacy}","received_events_url":"https://api.github.com/users/NicoNes/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/NicoNes/Resteasy","description":"REST and JAXRS","fork":true,"url":"https://api.github.com/repos/NicoNes/Resteasy","forks_url":"https://api.github.com/repos/NicoNes/Resteasy/forks","keys_url":"https://api.github.com/repos/NicoNes/Resteasy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NicoNes/Resteasy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NicoNes/Resteasy/teams","hooks_url":"https://api.github.com/repos/NicoNes/Resteasy/hooks","issue_events_url":"https://api.github.com/repos/NicoNes/Resteasy/issues/events{/number}","events_url":"https://api.github.com/repos/NicoNes/Resteasy/events","assignees_url":"https://api.github.com/repos/NicoNes/Resteasy/assignees{/user}","branches_url":"https://api.github.com/repos/NicoNes/Resteasy/branches{/branch}","tags_url":"https://api.github.com/repos/NicoNes/Resteasy/tags","blobs_url":"https://api.github.com/repos/NicoNes/Resteasy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NicoNes/Resteasy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NicoNes/Resteasy/git/refs{/sha}","trees_url":"https://api.github.com/repos/NicoNes/Resteasy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NicoNes/Resteasy/statuses/{sha}","languages_url":"https://api.github.com/repos/NicoNes/Resteasy/languages","stargazers_url":"https://api.github.com/repos/NicoNes/Resteasy/stargazers","contributors_url":"https://api.github.com/repos/NicoNes/Resteasy/contributors","subscribers_url":"https://api.github.com/repos/NicoNes/Resteasy/subscribers","subscription_url":"https://api.github.com/repos/NicoNes/Resteasy/subscription","commits_url":"https://api.github.com/repos/NicoNes/Resteasy/commits{/sha}","git_commits_url":"https://api.github.com/repos/NicoNes/Resteasy/git/commits{/sha}","comments_url":"https://api.github.com/repos/NicoNes/Resteasy/comments{/number}","issue_comment_url":"https://api.github.com/repos/NicoNes/Resteasy/issues/comments{/number}","contents_url":"https://api.github.com/repos/NicoNes/Resteasy/contents/{+path}","compare_url":"https://api.github.com/repos/NicoNes/Resteasy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NicoNes/Resteasy/merges","archive_url":"https://api.github.com/repos/NicoNes/Resteasy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NicoNes/Resteasy/downloads","issues_url":"https://api.github.com/repos/NicoNes/Resteasy/issues{/number}","pulls_url":"https://api.github.com/repos/NicoNes/Resteasy/pulls{/number}","milestones_url":"https://api.github.com/repos/NicoNes/Resteasy/milestones{/number}","notifications_url":"https://api.github.com/repos/NicoNes/Resteasy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NicoNes/Resteasy/labels{/name}","releases_url":"https://api.github.com/repos/NicoNes/Resteasy/releases{/id}","deployments_url":"https://api.github.com/repos/NicoNes/Resteasy/deployments","created_at":"2016-05-06T10:45:11Z","updated_at":"2016-05-06T10:45:20Z","pushed_at":"2016-05-06T23:36:16Z","git_url":"git://github.com/NicoNes/Resteasy.git","ssh_url":"git@github.com:NicoNes/Resteasy.git","clone_url":"https://github.com/NicoNes/Resteasy.git","svn_url":"https://github.com/NicoNes/Resteasy","homepage":"http://jboss.org/resteasy","size":28351,"stargazers_count":0,"watchers_count":0,"language":"Java","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":"resteasy:master","ref":"master","sha":"a6f5e0777f78bbef8f742f354cfa8d52b197238a","user":{"login":"resteasy","id":1252373,"avatar_url":"https://avatars.githubusercontent.com/u/1252373?v=3","gravatar_id":"","url":"https://api.github.com/users/resteasy","html_url":"https://github.com/resteasy","followers_url":"https://api.github.com/users/resteasy/followers","following_url":"https://api.github.com/users/resteasy/following{/other_user}","gists_url":"https://api.github.com/users/resteasy/gists{/gist_id}","starred_url":"https://api.github.com/users/resteasy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/resteasy/subscriptions","organizations_url":"https://api.github.com/users/resteasy/orgs","repos_url":"https://api.github.com/users/resteasy/repos","events_url":"https://api.github.com/users/resteasy/events{/privacy}","received_events_url":"https://api.github.com/users/resteasy/received_events","type":"Organization","site_admin":false},"repo":{"id":2948043,"name":"Resteasy","full_name":"resteasy/Resteasy","owner":{"login":"resteasy","id":1252373,"avatar_url":"https://avatars.githubusercontent.com/u/1252373?v=3","gravatar_id":"","url":"https://api.github.com/users/resteasy","html_url":"https://github.com/resteasy","followers_url":"https://api.github.com/users/resteasy/followers","following_url":"https://api.github.com/users/resteasy/following{/other_user}","gists_url":"https://api.github.com/users/resteasy/gists{/gist_id}","starred_url":"https://api.github.com/users/resteasy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/resteasy/subscriptions","organizations_url":"https://api.github.com/users/resteasy/orgs","repos_url":"https://api.github.com/users/resteasy/repos","events_url":"https://api.github.com/users/resteasy/events{/privacy}","received_events_url":"https://api.github.com/users/resteasy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/resteasy/Resteasy","description":"REST and JAXRS","fork":false,"url":"https://api.github.com/repos/resteasy/Resteasy","forks_url":"https://api.github.com/repos/resteasy/Resteasy/forks","keys_url":"https://api.github.com/repos/resteasy/Resteasy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/resteasy/Resteasy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/resteasy/Resteasy/teams","hooks_url":"https://api.github.com/repos/resteasy/Resteasy/hooks","issue_events_url":"https://api.github.com/repos/resteasy/Resteasy/issues/events{/number}","events_url":"https://api.github.com/repos/resteasy/Resteasy/events","assignees_url":"https://api.github.com/repos/resteasy/Resteasy/assignees{/user}","branches_url":"https://api.github.com/repos/resteasy/Resteasy/branches{/branch}","tags_url":"https://api.github.com/repos/resteasy/Resteasy/tags","blobs_url":"https://api.github.com/repos/resteasy/Resteasy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/resteasy/Resteasy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/resteasy/Resteasy/git/refs{/sha}","trees_url":"https://api.github.com/repos/resteasy/Resteasy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/resteasy/Resteasy/statuses/{sha}","languages_url":"https://api.github.com/repos/resteasy/Resteasy/languages","stargazers_url":"https://api.github.com/repos/resteasy/Resteasy/stargazers","contributors_url":"https://api.github.com/repos/resteasy/Resteasy/contributors","subscribers_url":"https://api.github.com/repos/resteasy/Resteasy/subscribers","subscription_url":"https://api.github.com/repos/resteasy/Resteasy/subscription","commits_url":"https://api.github.com/repos/resteasy/Resteasy/commits{/sha}","git_commits_url":"https://api.github.com/repos/resteasy/Resteasy/git/commits{/sha}","comments_url":"https://api.github.com/repos/resteasy/Resteasy/comments{/number}","issue_comment_url":"https://api.github.com/repos/resteasy/Resteasy/issues/comments{/number}","contents_url":"https://api.github.com/repos/resteasy/Resteasy/contents/{+path}","compare_url":"https://api.github.com/repos/resteasy/Resteasy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/resteasy/Resteasy/merges","archive_url":"https://api.github.com/repos/resteasy/Resteasy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/resteasy/Resteasy/downloads","issues_url":"https://api.github.com/repos/resteasy/Resteasy/issues{/number}","pulls_url":"https://api.github.com/repos/resteasy/Resteasy/pulls{/number}","milestones_url":"https://api.github.com/repos/resteasy/Resteasy/milestones{/number}","notifications_url":"https://api.github.com/repos/resteasy/Resteasy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/resteasy/Resteasy/labels{/name}","releases_url":"https://api.github.com/repos/resteasy/Resteasy/releases{/id}","deployments_url":"https://api.github.com/repos/resteasy/Resteasy/deployments","created_at":"2011-12-09T15:15:43Z","updated_at":"2016-05-04T16:24:05Z","pushed_at":"2016-05-05T22:28:53Z","git_url":"git://github.com/resteasy/Resteasy.git","ssh_url":"git@github.com:resteasy/Resteasy.git","clone_url":"https://github.com/resteasy/Resteasy.git","svn_url":"https://github.com/resteasy/Resteasy","homepage":"http://jboss.org/resteasy","size":30876,"stargazers_count":465,"watchers_count":465,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":575,"mirror_url":null,"open_issues_count":59,"forks":575,"open_issues":59,"watchers":465,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/resteasy/Resteasy/pulls/791"},"html":{"href":"https://github.com/resteasy/Resteasy/pull/791"},"issue":{"href":"https://api.github.com/repos/resteasy/Resteasy/issues/791"},"comments":{"href":"https://api.github.com/repos/resteasy/Resteasy/issues/791/comments"},"review_comments":{"href":"https://api.github.com/repos/resteasy/Resteasy/pulls/791/comments"},"review_comment":{"href":"https://api.github.com/repos/resteasy/Resteasy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/resteasy/Resteasy/pulls/791/commits"},"statuses":{"href":"https://api.github.com/repos/resteasy/Resteasy/statuses/9bdc0f922a913bde4f64ac059d4533cadd68b30c"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":2,"additions":172,"deletions":123,"changed_files":2}}