Small optimisation

This commit is contained in:
Simon Sessingø
2016-11-19 06:01:53 +01:00
parent d4a04920b8
commit d1f33d9b01
+4 -2
View File
@@ -137,6 +137,7 @@ class RouterBase
protected function processRoutes(array $routes, array $settings = array(), array $prefixes = array(), RouterEntry $parent = null) { protected function processRoutes(array $routes, array $settings = array(), array $prefixes = array(), RouterEntry $parent = null) {
$mergedSettings = []; $mergedSettings = [];
$mergedPrefixes = [];
// Loop through each route-request // Loop through each route-request
/* @var $route RouterEntry */ /* @var $route RouterEntry */
@@ -146,6 +147,7 @@ class RouterBase
if ($parent !== null) { if ($parent !== null) {
$route->setParent($parent); $route->setParent($parent);
$mergedPrefixes = [];
} }
if ($route instanceof ILoadableRoute) { if ($route instanceof ILoadableRoute) {
@@ -159,7 +161,7 @@ class RouterBase
} elseif ($route instanceof RouterGroup) { } elseif ($route instanceof RouterGroup) {
if ($route->getPrefix() !== null && trim($route->getPrefix(), '/') !== '') { if ($route->getPrefix() !== null && trim($route->getPrefix(), '/') !== '') {
$prefixes[] = trim($route->getPrefix(), '/'); $mergedPrefixes[] = trim($route->getPrefix(), '/');
} }
if ($route->getCallback() !== null && is_callable($route->getCallback())) { if ($route->getCallback() !== null && is_callable($route->getCallback())) {
@@ -186,7 +188,7 @@ class RouterBase
$this->backStack = array(); $this->backStack = array();
// Route any routes added to the backstack // Route any routes added to the backstack
$this->processRoutes($backStack, $mergedSettings, $prefixes, $route); $this->processRoutes($backStack, $mergedSettings, $mergedPrefixes, $route);
} }
} }
} }