Skip to content

Commit

Permalink
Merge pull request #5918 from iRedds/routecollection-getroutes
Browse files Browse the repository at this point in the history
Optimizing the RouteCollection::getRoutes() method
  • Loading branch information
paulbalandan authored Apr 23, 2022
2 parents 73c4e25 + 2c77ee5 commit ec0f3fa
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions system/Router/RouteCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -452,16 +452,12 @@ public function getRoutes(?string $verb = null): array
// we might need to do.
$this->discoverRoutes();

$routes = [];
$collection = [];
$routes = [];

if (isset($this->routes[$verb])) {
// Keep current verb's routes at the beginning, so they're matched
// before any of the generic, "add" routes.
if (isset($this->routes['*'])) {
$extraRules = array_diff_key($this->routes['*'], $this->routes[$verb]);
$collection = array_merge($this->routes[$verb], $extraRules);
}
$collection = $this->routes[$verb] + ($this->routes['*'] ?? []);

foreach ($collection as $r) {
$key = key($r['route']);
Expand Down

0 comments on commit ec0f3fa

Please sign in to comment.