1
0
Fork 0

Revert "Minimize URI parsing in loop"

This reverts commit 8d439f82f5.
pull/281/head
Trevor Bortins 2017-02-06 14:38:43 -08:00
parent 8d439f82f5
commit 0a69c7292a
1 changed files with 3 additions and 14 deletions

View File

@ -138,22 +138,11 @@ function stripStringOverlap(string $a, string $b): string
* in ascending order. * in ascending order.
* *
* @param array * @param array
* @return void * @return array
*/ */
function sortUrisLevelOrder(&$uriList) function sortUrisLevelOrder(&$uriList)
{ {
// Parse URIs so we are not continually parsing them while sorting usort($uriList, function ($a, $b) {
$parsedUriList = array_map(function ($uri) { return substr_count(Uri\parse($a)['path'], '/') - substr_count(Uri\parse($b)['path'], '/');
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'], '/');
}); });
// Reassemble the URIs
$uriList = array_map(function ($parsedUri) {
return Uri\build($parsedUri);
}, $parsedUriList);
} }