Skip to content

Commit

Permalink
Foreach is faster than array_map.
Browse files Browse the repository at this point in the history
When connecting 500 routes, this method was taking 6ms on my machine.
Afterwards it takes 0.
  • Loading branch information
markstory committed Dec 16, 2017
1 parent d5e9ff2 commit 9faf5b8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Routing/Route/Route.php
Expand Up @@ -155,7 +155,10 @@ public function extensions($extensions = null)
*/
public function setExtensions(array $extensions)
{
$this->_extensions = array_map('strtolower', $extensions);
$this->_extensions = [];
foreach ($extensions as $ext) {
$this->_extensions[] = strtolower($ext);
}

return $this;
}
Expand Down

0 comments on commit 9faf5b8

Please sign in to comment.