Skip to content

Commit

Permalink
Add a small optimization for reverse routing.
Browse files Browse the repository at this point in the history
There is no reason to check the routes of a collection if the scope
parameters don't intersect with the URL parameters.
  • Loading branch information
markstory committed Jun 29, 2014
1 parent 41a97c2 commit 7ce2f45
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Routing/Router.php
Expand Up @@ -826,6 +826,11 @@ protected static function _match($url) {

// No quick win, iterate and hope for the best.
foreach (static::$_pathScopes as $key => $collection) {
$params = $collection->params();
// No point in checking the routes if the scope params are wrong.
if (array_intersect_key($url, $params) !== $params) {
continue;
}
$match = $collection->match($url, static::$_requestContext);
if ($match !== false) {
return $match;
Expand Down

0 comments on commit 7ce2f45

Please sign in to comment.