From 2c77ee5da6f611df73d301281520960a4699d20f Mon Sep 17 00:00:00 2001 From: Andrey Pyzhikov <5071@mail.ru> Date: Sat, 23 Apr 2022 03:22:31 +0800 Subject: [PATCH] Optimizing the RouteCollection::getRoutes() method Signed-off-by: Andrey Pyzhikov <5071@mail.ru> --- system/Router/RouteCollection.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/system/Router/RouteCollection.php b/system/Router/RouteCollection.php index 4bb048991a99..120ed99c73ee 100644 --- a/system/Router/RouteCollection.php +++ b/system/Router/RouteCollection.php @@ -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']);