From f778c1f4a26f0f57a4db6cd09dcb8767ae236dac Mon Sep 17 00:00:00 2001 From: William Date: Mon, 30 Jan 2023 22:18:57 +0100 Subject: [PATCH] Mini optimization --- app/WillySoft/Http/Route.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/WillySoft/Http/Route.php b/app/WillySoft/Http/Route.php index 89891c1..9d7d666 100644 --- a/app/WillySoft/Http/Route.php +++ b/app/WillySoft/Http/Route.php @@ -12,9 +12,14 @@ abstract class Route { array_map(strtoupper(...), explode('|', $methods)) )) return; - $request_path_parts = explode('/', urldecode( - strtok($_SERVER['REQUEST_URI'], '?') - )); + static $cache; + if (!isset($cache)) { + $cache = explode('/', urldecode( + strtok($_SERVER['REQUEST_URI'], '?') + )); + } + $request_path_parts = $cache; + $path_parts = explode('/', $path); $callback_args = []; for ($i=0; $i < count($path_parts); $i++) {