From 292db44e485e92495cdbcc0d52b658ed0ca8c02f Mon Sep 17 00:00:00 2001 From: "Buster \"Silver Eagle\" Neece" Date: Mon, 7 Sep 2020 17:59:57 -0500 Subject: [PATCH] Remove redundant check of domains. --- src/App.php | 1 - src/Router/Route.php | 10 ---------- src/Router/Router.php | 7 ++++++- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/App.php b/src/App.php index e67c6bb..a7c24a2 100644 --- a/src/App.php +++ b/src/App.php @@ -518,7 +518,6 @@ class App $appClass->getNamespaceName() ); - // Cache routes before weighing. $this->router->cache(); $this->logger->debug(sprintf( diff --git a/src/Router/Route.php b/src/Router/Route.php index d999a47..2ab1794 100644 --- a/src/Router/Route.php +++ b/src/Router/Route.php @@ -133,16 +133,6 @@ class Route public function populateRoute(App $app): App { - /*$this->logger->debug(sprintf( - 'Router Populating: %s %s', - $this->getHttpMethod(), - $this->getRouterPattern() - ));*/ - - if ($this->hasValidDomains() && !$this->isInContainedInValidDomains()) { - return $app; - } - $mapping = $app->map( [$this->getHttpMethod()], $this->getRouterPattern(), diff --git a/src/Router/Router.php b/src/Router/Router.php index a99f8bf..cf34664 100644 --- a/src/Router/Router.php +++ b/src/Router/Router.php @@ -120,7 +120,12 @@ class Router $allocatedRoutes = []; if (is_array($this->routes) && count($this->routes) > 0) { uasort($this->routes, function (Route $a, Route $b) { - return $a->getWeight() > $b->getWeight(); + $a1 = $a->getWeight(); + $b1 = $b->getWeight(); + if ($a1 === $b1) { + return 0; + } + return ($a1 > $b1) ? +1 : -1; }); foreach ($this->routes as $index => $route) {