{"action":"opened","issue":{"url":"https://api.github.com/repos/akeeba/fof/issues/473","labels_url":"https://api.github.com/repos/akeeba/fof/issues/473/labels{/name}","comments_url":"https://api.github.com/repos/akeeba/fof/issues/473/comments","events_url":"https://api.github.com/repos/akeeba/fof/issues/473/events","html_url":"https://github.com/akeeba/fof/issues/473","id":58171760,"number":473,"title":"Autoloader performance","user":{"login":"Eighke","id":2734125,"avatar_url":"https://avatars.githubusercontent.com/u/2734125?v=3","gravatar_id":"","url":"https://api.github.com/users/Eighke","html_url":"https://github.com/Eighke","followers_url":"https://api.github.com/users/Eighke/followers","following_url":"https://api.github.com/users/Eighke/following{/other_user}","gists_url":"https://api.github.com/users/Eighke/gists{/gist_id}","starred_url":"https://api.github.com/users/Eighke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Eighke/subscriptions","organizations_url":"https://api.github.com/users/Eighke/orgs","repos_url":"https://api.github.com/users/Eighke/repos","events_url":"https://api.github.com/users/Eighke/events{/privacy}","received_events_url":"https://api.github.com/users/Eighke/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-02-19T06:10:56Z","updated_at":"2015-02-19T06:10:56Z","closed_at":null,"body":"Well I was searching why the \"Switch\" doesn't work with Form, but I found something else.\r\n\r\nThe Autoloader::addMap() is called 7 times. With those values:\r\n```php\r\nAutoloader::addMap('FOF30\\\\', array(realpath(__DIR__ . '/..')));\r\nAutoloader::addMap('Toto\\Site\\','/components/com_toto');\r\nAutoloader::addMap('Toto\\Admin\\','/administrator/components/com_toto');\r\n\r\nAutoloader::addMap('Toto\\Site\\','/components/com_toto');\r\nAutoloader::addMap('Toto\\Admin\\','/administrator/components/com_toto');\r\n\r\nAutoloader::addMap('Toto\\Site\\','/components/com_toto');\r\nAutoloader::addMap('Toto\\Admin\\','/administrator/components/com_toto');\r\n```\r\nThe 3 firsts look normal. But the 4 others not. Well it is not a big deal but the problem is that we do a foreach on `$this->prefixDirs[$prefix]`. And we currently got 3 times the same path. A `print_r($this->prefixDirs[$prefix])`.\r\n\r\n```\r\nArray\r\n(\r\n    [FOF30\\] => Array\r\n        (\r\n            [0] => /libraries/fof3\r\n        )\r\n\r\n    [Ngcontents\\Site\\] => Array\r\n        (\r\n            [0] => /components/com_toto\r\n            [1] => /components/com_toto\r\n            [2] => /components/com_toto\r\n        )\r\n\r\n    [Ngcontents\\Admin\\] => Array\r\n        (\r\n            [0] => /administrator/components/com_toto\r\n            [1] => /administrator/components/com_toto\r\n            [2] => /administrator/components/com_toto\r\n        )\r\n\r\n)\r\n```\r\nSo the Autoloader will check 3 times the same path (3 * 2 for SwitchFactory), for every class. I think it's a small perf down, but we could remove it using a `in_array` when adding the new path."}}