Skip to content

Commit

Permalink
remove unnecessary array_unique
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Jul 9, 2020
1 parent d9a793b commit 041ee1a
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions system/Autoloader/FileLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,23 +244,20 @@ public function search(string $path, string $ext = 'php', bool $prioritizeApp =
if (isset($namespace['path']) && is_file($namespace['path'] . $path))
{
$fullPath = $namespace['path'] . $path;
if ($prioritizeApp || strpos($fullPath, APPPATH) !== 0)
if (($prioritizeApp || strpos($fullPath, APPPATH) !== 0) && ! in_array($fullPath, $foundPaths, true))
{
$foundPaths[] = $fullPath;
}
else
{
if (! in_array($fullPath, $appPaths, true) && strpos($fullPath, APPPATH) === 0)
if (strpos($fullPath, APPPATH) === 0 && ! in_array($fullPath, $appPaths, true))
{
$appPaths[] = $fullPath;
}
}
}
}

// Remove any duplicates
$foundPaths = array_unique($foundPaths);

if (! $prioritizeApp && ! empty($appPaths))
{
$foundPaths = array_merge($foundPaths, $appPaths);
Expand Down

0 comments on commit 041ee1a

Please sign in to comment.