{"action":"created","issue":{"url":"https://api.github.com/repos/symfony/symfony/issues/24556","repository_url":"https://api.github.com/repos/symfony/symfony","labels_url":"https://api.github.com/repos/symfony/symfony/issues/24556/labels{/name}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/24556/comments","events_url":"https://api.github.com/repos/symfony/symfony/issues/24556/events","html_url":"https://github.com/symfony/symfony/pull/24556","id":265449834,"number":24556,"title":"[Routing] Ensure uniqueness without repeated check","user":{"login":"endroid","id":537253,"avatar_url":"https://avatars1.githubusercontent.com/u/537253?v=4","gravatar_id":"","url":"https://api.github.com/users/endroid","html_url":"https://github.com/endroid","followers_url":"https://api.github.com/users/endroid/followers","following_url":"https://api.github.com/users/endroid/following{/other_user}","gists_url":"https://api.github.com/users/endroid/gists{/gist_id}","starred_url":"https://api.github.com/users/endroid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/endroid/subscriptions","organizations_url":"https://api.github.com/users/endroid/orgs","repos_url":"https://api.github.com/users/endroid/repos","events_url":"https://api.github.com/users/endroid/events{/privacy}","received_events_url":"https://api.github.com/users/endroid/received_events","type":"User","site_admin":false},"labels":[{"id":111254,"url":"https://api.github.com/repos/symfony/symfony/labels/Routing","name":"Routing","color":"DDDDDD","default":false},{"id":237003792,"url":"https://api.github.com/repos/symfony/symfony/labels/Status:%20Needs%20Review","name":"Status: Needs Review","color":"ededed","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-10-14T00:27:49Z","updated_at":"2017-10-14T18:47:35Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/symfony/symfony/pulls/24556","html_url":"https://github.com/symfony/symfony/pull/24556","diff_url":"https://github.com/symfony/symfony/pull/24556.diff","patch_url":"https://github.com/symfony/symfony/pull/24556.patch"},"body":"| Q             | A\r\n| ------------- | ---\r\n| Branch?       | 2.7\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\nThe RouteCollection ensures uniqueness of resources by using array_unique. The current implementation suffers from the following problems.\r\n\r\n1. The array_unique method calls __toString for every element in the array but it is very inefficient in terms of the number of calls made. I.e. if the array has 50 elements it does not do 50 __toString calls. I did some tests with Blackfire in PHP 7.1 and found the following numbers.\r\n\r\n25 elements => 240 calls\r\n50 elements => 607 calls\r\n100 elements => 1382 calls\r\n200 elements => 3333 calls\r\n\r\n2. The array_unique function is called every time the getResources() method is called, even when the resources did not change in the mean time. Combined with the above this leads to lower performance.\r\n\r\nMany applications have a low number of routes so this is not a big issue. But for larger applications or bundles that generate routes (i.e. for CRUD or API / doc generation) this will have a bigger impact."},"comment":{"url":"https://api.github.com/repos/symfony/symfony/issues/comments/336655884","html_url":"https://github.com/symfony/symfony/pull/24556#issuecomment-336655884","issue_url":"https://api.github.com/repos/symfony/symfony/issues/24556","id":336655884,"user":{"login":"endroid","id":537253,"avatar_url":"https://avatars1.githubusercontent.com/u/537253?v=4","gravatar_id":"","url":"https://api.github.com/users/endroid","html_url":"https://github.com/endroid","followers_url":"https://api.github.com/users/endroid/followers","following_url":"https://api.github.com/users/endroid/following{/other_user}","gists_url":"https://api.github.com/users/endroid/gists{/gist_id}","starred_url":"https://api.github.com/users/endroid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/endroid/subscriptions","organizations_url":"https://api.github.com/users/endroid/orgs","repos_url":"https://api.github.com/users/endroid/repos","events_url":"https://api.github.com/users/endroid/events{/privacy}","received_events_url":"https://api.github.com/users/endroid/received_events","type":"User","site_admin":false},"created_at":"2017-10-14T18:47:35Z","updated_at":"2017-10-14T18:47:35Z","author_association":"CONTRIBUTOR","body":"I think so. I encountered the issue in an application with a lot of routes where on my development environment it took 1.35s for each page load and with the optimization above it took only 250ms. So I think it is still relevant but for production it might not be."}}
{"actor":{"display_login":"endroid"}}