{"action":"created","comment":{"url":"https://api.github.com/repos/symfony/symfony/pulls/comments/166254044","pull_request_review_id":94297873,"id":166254044,"diff_hunk":"@@ -162,107 +164,214 @@ private function compileRoutes(RouteCollection $routes, $supportsRedirections)\n         return $code;\n     }\n \n-    private function buildStaticPrefixCollection(DumperCollection $collection)\n+    private function groupStaticRoutes(RouteCollection $collection, bool $supportsRedirections): array\n     {\n-        $prefixCollection = new StaticPrefixCollection();\n+        $staticRoutes = array();\n+        $dynamicRoutes = new RouteCollection();\n+        $dynamicRegex = array();\n+        $code = '';\n \n-        foreach ($collection as $dumperRoute) {\n-            $prefix = $dumperRoute->getRoute()->compile()->getStaticPrefix();\n-            $prefixCollection->addRoute($prefix, $dumperRoute);\n-        }\n+        foreach ($collection->all() as $name => $route) {\n+            $compiledRoute = $route->compile();\n+            $regex = $compiledRoute->getRegex();\n+            $methods = $route->getMethods();","path":"src/Symfony/Component/Routing/Matcher/Dumper/PhpMatcherDumper.php","position":null,"original_position":46,"commit_id":"9ba72eb3af0bf0196ecefa09df8cffb591a95b9e","original_commit_id":"3b78aa5329f677c699803709db86b58389d25a07","user":{"login":"nicolas-grekas","id":243674,"avatar_url":"https://avatars3.githubusercontent.com/u/243674?v=4","gravatar_id":"","url":"https://api.github.com/users/nicolas-grekas","html_url":"https://github.com/nicolas-grekas","followers_url":"https://api.github.com/users/nicolas-grekas/followers","following_url":"https://api.github.com/users/nicolas-grekas/following{/other_user}","gists_url":"https://api.github.com/users/nicolas-grekas/gists{/gist_id}","starred_url":"https://api.github.com/users/nicolas-grekas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicolas-grekas/subscriptions","organizations_url":"https://api.github.com/users/nicolas-grekas/orgs","repos_url":"https://api.github.com/users/nicolas-grekas/repos","events_url":"https://api.github.com/users/nicolas-grekas/events{/privacy}","received_events_url":"https://api.github.com/users/nicolas-grekas/received_events","type":"User","site_admin":false},"body":"fixed thanks","created_at":"2018-02-06T10:45:11Z","updated_at":"2018-02-06T10:45:11Z","html_url":"https://github.com/symfony/symfony/pull/26059#discussion_r166254044","pull_request_url":"https://api.github.com/repos/symfony/symfony/pulls/26059","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony/pulls/comments/166254044"},"html":{"href":"https://github.com/symfony/symfony/pull/26059#discussion_r166254044"},"pull_request":{"href":"https://api.github.com/repos/symfony/symfony/pulls/26059"}},"in_reply_to_id":166253513},"pull_request":{"url":"https://api.github.com/repos/symfony/symfony/pulls/26059","id":167227989,"html_url":"https://github.com/symfony/symfony/pull/26059","diff_url":"https://github.com/symfony/symfony/pull/26059.diff","patch_url":"https://github.com/symfony/symfony/pull/26059.patch","issue_url":"https://api.github.com/repos/symfony/symfony/issues/26059","number":26059,"state":"open","locked":false,"title":" [Routing] Match 5x faster by compiling routes in one regexp","user":{"login":"nicolas-grekas","id":243674,"avatar_url":"https://avatars3.githubusercontent.com/u/243674?v=4","gravatar_id":"","url":"https://api.github.com/users/nicolas-grekas","html_url":"https://github.com/nicolas-grekas","followers_url":"https://api.github.com/users/nicolas-grekas/followers","following_url":"https://api.github.com/users/nicolas-grekas/following{/other_user}","gists_url":"https://api.github.com/users/nicolas-grekas/gists{/gist_id}","starred_url":"https://api.github.com/users/nicolas-grekas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicolas-grekas/subscriptions","organizations_url":"https://api.github.com/users/nicolas-grekas/orgs","repos_url":"https://api.github.com/users/nicolas-grekas/repos","events_url":"https://api.github.com/users/nicolas-grekas/events{/privacy}","received_events_url":"https://api.github.com/users/nicolas-grekas/received_events","type":"User","site_admin":false},"body":"| Q             | A\r\n| ------------- | ---\r\n| Branch?       | master\r\n| Bug fix?      | no\r\n| New feature?  | no\r\n| BC breaks?    | no\r\n| Deprecations? | no\r\n| Tests pass?   | yes\r\n| Fixed tickets | -\r\n| License       | MIT\r\n| Doc PR        | -\r\n\r\nBuilds on top of #25961 and http://nikic.github.io/2014/02/18/Fast-request-routing-using-regular-expressions.html to make routing 5x faster (measured when matching the last dynamic route of 400 static + 400 dynamic routes.)\r\n\r\nMore benchs welcomed.\r\n\r\nCould be further improved (in another PR, by someone else, if worth it):\r\n- make hosts benefit from the same optimization\r\n- group consecutive same-regex in a single \"case\"\r\n\r\nHere is my benchmarking code:\r\n\r\n```php\r\n<?php\r\n\r\nnamespace Symfony\\Component\\Routing;\r\n\r\nrequire 'vendor/autoload.php';\r\n\r\n$routes = new RouteCollection();\r\n\r\nfor ($i = 0; $i < 400; ++$i) {\r\n    $routes->add('r'.$i, new Route('/abc'.$i));\r\n    $routes->add('f'.$i, new Route('/abc{foo}/'.$i));\r\n}\r\n\r\n$dumper = new Matcher\\Dumper\\PhpMatcherDumper($routes);\r\n\r\neval('?'.'>'.$dumper->dump());\r\n\r\n$router = new \\ProjectUrlMatcher(new RequestContext());\r\n\r\n$i = 10000;\r\n$s = microtime(1);\r\n\r\nwhile (--$i) {\r\n    $router->match('/abcdef/399');\r\n}\r\n\r\necho 'Symfony: ', 1000 * (microtime(1) - $s), \"\\n\";\r\n\r\nnamespace FastRoute;\r\n\r\n$dispatcher = simpleDispatcher(function(RouteCollector $r) {\r\n    for ($i = 0; $i < 400; ++$i) {\r\n        $r->addRoute('GET', '/abc'.$i, 'r'.$i);\r\n        $r->addRoute('GET', '/abc{foo}/'.$i, 'f'.$i);\r\n    }\r\n});\r\n\r\n$i = 10000;\r\n$s = microtime(1);\r\n\r\nwhile (--$i) {\r\n    $dispatcher->dispatch('GET', '/abcdef/399');\r\n}\r\n\r\necho 'FastRoute: ', 1000 * (microtime(1) - $s), \"\\n\";\r\n```","created_at":"2018-02-05T19:04:40Z","updated_at":"2018-02-06T10:45:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"784d90627d5798dbdbbe10788cdbe87e53a8c218","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"milestone":{"url":"https://api.github.com/repos/symfony/symfony/milestones/17","html_url":"https://github.com/symfony/symfony/milestone/17","labels_url":"https://api.github.com/repos/symfony/symfony/milestones/17/labels","id":2795131,"number":17,"title":"4.1","description":"https://symfony.com/roadmap?version=4.1#checker","creator":{"login":"nicolas-grekas","id":243674,"avatar_url":"https://avatars3.githubusercontent.com/u/243674?v=4","gravatar_id":"","url":"https://api.github.com/users/nicolas-grekas","html_url":"https://github.com/nicolas-grekas","followers_url":"https://api.github.com/users/nicolas-grekas/followers","following_url":"https://api.github.com/users/nicolas-grekas/following{/other_user}","gists_url":"https://api.github.com/users/nicolas-grekas/gists{/gist_id}","starred_url":"https://api.github.com/users/nicolas-grekas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicolas-grekas/subscriptions","organizations_url":"https://api.github.com/users/nicolas-grekas/orgs","repos_url":"https://api.github.com/users/nicolas-grekas/repos","events_url":"https://api.github.com/users/nicolas-grekas/events{/privacy}","received_events_url":"https://api.github.com/users/nicolas-grekas/received_events","type":"User","site_admin":false},"open_issues":134,"closed_issues":115,"state":"open","created_at":"2017-09-26T15:40:00Z","updated_at":"2018-02-06T07:24:58Z","due_on":"2018-05-31T07:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/symfony/symfony/pulls/26059/commits","review_comments_url":"https://api.github.com/repos/symfony/symfony/pulls/26059/comments","review_comment_url":"https://api.github.com/repos/symfony/symfony/pulls/comments{/number}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/26059/comments","statuses_url":"https://api.github.com/repos/symfony/symfony/statuses/9ba72eb3af0bf0196ecefa09df8cffb591a95b9e","head":{"label":"nicolas-grekas:router-one-rx","ref":"router-one-rx","sha":"9ba72eb3af0bf0196ecefa09df8cffb591a95b9e","user":{"login":"nicolas-grekas","id":243674,"avatar_url":"https://avatars3.githubusercontent.com/u/243674?v=4","gravatar_id":"","url":"https://api.github.com/users/nicolas-grekas","html_url":"https://github.com/nicolas-grekas","followers_url":"https://api.github.com/users/nicolas-grekas/followers","following_url":"https://api.github.com/users/nicolas-grekas/following{/other_user}","gists_url":"https://api.github.com/users/nicolas-grekas/gists{/gist_id}","starred_url":"https://api.github.com/users/nicolas-grekas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicolas-grekas/subscriptions","organizations_url":"https://api.github.com/users/nicolas-grekas/orgs","repos_url":"https://api.github.com/users/nicolas-grekas/repos","events_url":"https://api.github.com/users/nicolas-grekas/events{/privacy}","received_events_url":"https://api.github.com/users/nicolas-grekas/received_events","type":"User","site_admin":false},"repo":{"id":15110606,"name":"symfony","full_name":"nicolas-grekas/symfony","owner":{"login":"nicolas-grekas","id":243674,"avatar_url":"https://avatars3.githubusercontent.com/u/243674?v=4","gravatar_id":"","url":"https://api.github.com/users/nicolas-grekas","html_url":"https://github.com/nicolas-grekas","followers_url":"https://api.github.com/users/nicolas-grekas/followers","following_url":"https://api.github.com/users/nicolas-grekas/following{/other_user}","gists_url":"https://api.github.com/users/nicolas-grekas/gists{/gist_id}","starred_url":"https://api.github.com/users/nicolas-grekas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicolas-grekas/subscriptions","organizations_url":"https://api.github.com/users/nicolas-grekas/orgs","repos_url":"https://api.github.com/users/nicolas-grekas/repos","events_url":"https://api.github.com/users/nicolas-grekas/events{/privacy}","received_events_url":"https://api.github.com/users/nicolas-grekas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nicolas-grekas/symfony","description":"The Symfony PHP framework","fork":true,"url":"https://api.github.com/repos/nicolas-grekas/symfony","forks_url":"https://api.github.com/repos/nicolas-grekas/symfony/forks","keys_url":"https://api.github.com/repos/nicolas-grekas/symfony/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nicolas-grekas/symfony/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nicolas-grekas/symfony/teams","hooks_url":"https://api.github.com/repos/nicolas-grekas/symfony/hooks","issue_events_url":"https://api.github.com/repos/nicolas-grekas/symfony/issues/events{/number}","events_url":"https://api.github.com/repos/nicolas-grekas/symfony/events","assignees_url":"https://api.github.com/repos/nicolas-grekas/symfony/assignees{/user}","branches_url":"https://api.github.com/repos/nicolas-grekas/symfony/branches{/branch}","tags_url":"https://api.github.com/repos/nicolas-grekas/symfony/tags","blobs_url":"https://api.github.com/repos/nicolas-grekas/symfony/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nicolas-grekas/symfony/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nicolas-grekas/symfony/git/refs{/sha}","trees_url":"https://api.github.com/repos/nicolas-grekas/symfony/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nicolas-grekas/symfony/statuses/{sha}","languages_url":"https://api.github.com/repos/nicolas-grekas/symfony/languages","stargazers_url":"https://api.github.com/repos/nicolas-grekas/symfony/stargazers","contributors_url":"https://api.github.com/repos/nicolas-grekas/symfony/contributors","subscribers_url":"https://api.github.com/repos/nicolas-grekas/symfony/subscribers","subscription_url":"https://api.github.com/repos/nicolas-grekas/symfony/subscription","commits_url":"https://api.github.com/repos/nicolas-grekas/symfony/commits{/sha}","git_commits_url":"https://api.github.com/repos/nicolas-grekas/symfony/git/commits{/sha}","comments_url":"https://api.github.com/repos/nicolas-grekas/symfony/comments{/number}","issue_comment_url":"https://api.github.com/repos/nicolas-grekas/symfony/issues/comments{/number}","contents_url":"https://api.github.com/repos/nicolas-grekas/symfony/contents/{+path}","compare_url":"https://api.github.com/repos/nicolas-grekas/symfony/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nicolas-grekas/symfony/merges","archive_url":"https://api.github.com/repos/nicolas-grekas/symfony/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nicolas-grekas/symfony/downloads","issues_url":"https://api.github.com/repos/nicolas-grekas/symfony/issues{/number}","pulls_url":"https://api.github.com/repos/nicolas-grekas/symfony/pulls{/number}","milestones_url":"https://api.github.com/repos/nicolas-grekas/symfony/milestones{/number}","notifications_url":"https://api.github.com/repos/nicolas-grekas/symfony/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nicolas-grekas/symfony/labels{/name}","releases_url":"https://api.github.com/repos/nicolas-grekas/symfony/releases{/id}","deployments_url":"https://api.github.com/repos/nicolas-grekas/symfony/deployments","created_at":"2013-12-11T15:13:36Z","updated_at":"2017-12-15T14:52:21Z","pushed_at":"2018-02-06T10:44:41Z","git_url":"git://github.com/nicolas-grekas/symfony.git","ssh_url":"git@github.com:nicolas-grekas/symfony.git","clone_url":"https://github.com/nicolas-grekas/symfony.git","svn_url":"https://github.com/nicolas-grekas/symfony","homepage":"symfony.com","size":108790,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":2,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":2,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"symfony:master","ref":"master","sha":"4e97b97215e6d14b8ece3b9a44dd7ee116b0d6bc","user":{"login":"symfony","id":143937,"avatar_url":"https://avatars3.githubusercontent.com/u/143937?v=4","gravatar_id":"","url":"https://api.github.com/users/symfony","html_url":"https://github.com/symfony","followers_url":"https://api.github.com/users/symfony/followers","following_url":"https://api.github.com/users/symfony/following{/other_user}","gists_url":"https://api.github.com/users/symfony/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony/subscriptions","organizations_url":"https://api.github.com/users/symfony/orgs","repos_url":"https://api.github.com/users/symfony/repos","events_url":"https://api.github.com/users/symfony/events{/privacy}","received_events_url":"https://api.github.com/users/symfony/received_events","type":"Organization","site_admin":false},"repo":{"id":458058,"name":"symfony","full_name":"symfony/symfony","owner":{"login":"symfony","id":143937,"avatar_url":"https://avatars3.githubusercontent.com/u/143937?v=4","gravatar_id":"","url":"https://api.github.com/users/symfony","html_url":"https://github.com/symfony","followers_url":"https://api.github.com/users/symfony/followers","following_url":"https://api.github.com/users/symfony/following{/other_user}","gists_url":"https://api.github.com/users/symfony/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony/subscriptions","organizations_url":"https://api.github.com/users/symfony/orgs","repos_url":"https://api.github.com/users/symfony/repos","events_url":"https://api.github.com/users/symfony/events{/privacy}","received_events_url":"https://api.github.com/users/symfony/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/symfony/symfony","description":"The Symfony PHP framework","fork":false,"url":"https://api.github.com/repos/symfony/symfony","forks_url":"https://api.github.com/repos/symfony/symfony/forks","keys_url":"https://api.github.com/repos/symfony/symfony/keys{/key_id}","collaborators_url":"https://api.github.com/repos/symfony/symfony/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/symfony/symfony/teams","hooks_url":"https://api.github.com/repos/symfony/symfony/hooks","issue_events_url":"https://api.github.com/repos/symfony/symfony/issues/events{/number}","events_url":"https://api.github.com/repos/symfony/symfony/events","assignees_url":"https://api.github.com/repos/symfony/symfony/assignees{/user}","branches_url":"https://api.github.com/repos/symfony/symfony/branches{/branch}","tags_url":"https://api.github.com/repos/symfony/symfony/tags","blobs_url":"https://api.github.com/repos/symfony/symfony/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/symfony/symfony/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/symfony/symfony/git/refs{/sha}","trees_url":"https://api.github.com/repos/symfony/symfony/git/trees{/sha}","statuses_url":"https://api.github.com/repos/symfony/symfony/statuses/{sha}","languages_url":"https://api.github.com/repos/symfony/symfony/languages","stargazers_url":"https://api.github.com/repos/symfony/symfony/stargazers","contributors_url":"https://api.github.com/repos/symfony/symfony/contributors","subscribers_url":"https://api.github.com/repos/symfony/symfony/subscribers","subscription_url":"https://api.github.com/repos/symfony/symfony/subscription","commits_url":"https://api.github.com/repos/symfony/symfony/commits{/sha}","git_commits_url":"https://api.github.com/repos/symfony/symfony/git/commits{/sha}","comments_url":"https://api.github.com/repos/symfony/symfony/comments{/number}","issue_comment_url":"https://api.github.com/repos/symfony/symfony/issues/comments{/number}","contents_url":"https://api.github.com/repos/symfony/symfony/contents/{+path}","compare_url":"https://api.github.com/repos/symfony/symfony/compare/{base}...{head}","merges_url":"https://api.github.com/repos/symfony/symfony/merges","archive_url":"https://api.github.com/repos/symfony/symfony/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/symfony/symfony/downloads","issues_url":"https://api.github.com/repos/symfony/symfony/issues{/number}","pulls_url":"https://api.github.com/repos/symfony/symfony/pulls{/number}","milestones_url":"https://api.github.com/repos/symfony/symfony/milestones{/number}","notifications_url":"https://api.github.com/repos/symfony/symfony/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/symfony/symfony/labels{/name}","releases_url":"https://api.github.com/repos/symfony/symfony/releases{/id}","deployments_url":"https://api.github.com/repos/symfony/symfony/deployments","created_at":"2010-01-04T14:21:21Z","updated_at":"2018-02-06T10:37:24Z","pushed_at":"2018-02-06T10:44:49Z","git_url":"git://github.com/symfony/symfony.git","ssh_url":"git@github.com:symfony/symfony.git","clone_url":"https://github.com/symfony/symfony.git","svn_url":"https://github.com/symfony/symfony","homepage":"symfony.com","size":113341,"stargazers_count":16508,"watchers_count":16508,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":5984,"mirror_url":null,"archived":false,"open_issues_count":838,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":5984,"open_issues":838,"watchers":16508,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony/pulls/26059"},"html":{"href":"https://github.com/symfony/symfony/pull/26059"},"issue":{"href":"https://api.github.com/repos/symfony/symfony/issues/26059"},"comments":{"href":"https://api.github.com/repos/symfony/symfony/issues/26059/comments"},"review_comments":{"href":"https://api.github.com/repos/symfony/symfony/pulls/26059/comments"},"review_comment":{"href":"https://api.github.com/repos/symfony/symfony/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/symfony/symfony/pulls/26059/commits"},"statuses":{"href":"https://api.github.com/repos/symfony/symfony/statuses/9ba72eb3af0bf0196ecefa09df8cffb591a95b9e"}},"author_association":"OWNER"}}
{"actor":{"display_login":"nicolas-grekas"}}