From 0a69c7292a3765507f834a50bc0f7111faa365a6 Mon Sep 17 00:00:00 2001 From: Trevor Bortins Date: Mon, 6 Feb 2017 14:38:43 -0800 Subject: [PATCH] Revert "Minimize URI parsing in loop" This reverts commit 8d439f82f5a17dbd5b49da4db00dfbeb278cb8f8. --- src/utils.php | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/utils.php b/src/utils.php index 2ed1c6a..c13f1be 100644 --- a/src/utils.php +++ b/src/utils.php @@ -138,22 +138,11 @@ function stripStringOverlap(string $a, string $b): string * in ascending order. * * @param array - * @return void + * @return array */ function sortUrisLevelOrder(&$uriList) { - // Parse URIs so we are not continually parsing them while sorting - $parsedUriList = array_map(function ($uri) { - return Uri\parse($uri); - }, $uriList); - - // Sort by number of slashes in parsed URI path, ascending - usort($parsedUriList, function ($a, $b) { - return substr_count($a['path'], '/') - substr_count($b['path'], '/'); + usort($uriList, function ($a, $b) { + return substr_count(Uri\parse($a)['path'], '/') - substr_count(Uri\parse($b)['path'], '/'); }); - - // Reassemble the URIs - $uriList = array_map(function ($parsedUri) { - return Uri\build($parsedUri); - }, $parsedUriList); }