Skip to content

Commit

Permalink
[Core] Remove loop on FilesFinder::findInDirectoriesAndFiles() (#2201)
Browse files Browse the repository at this point in the history
* [Core] Remove loop on FilesFinder::findInDirectoriesAndFiles()

* [ci-review] Rector Rectify

* rename variable

* clean up

Co-authored-by: GitHub Action <action@github.com>
  • Loading branch information
samsonasik and actions-user committed Apr 30, 2022
1 parent f30523f commit c8b47df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
6 changes: 5 additions & 1 deletion packages/Caching/UnchangedFilesFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function __construct(
}

/**
* @param SmartFileInfo[] $fileInfos
* @param SmartFileInfo[]|string[] $fileInfos
* @return SmartFileInfo[]
*/
public function filterAndJoinWithDependentFileInfos(array $fileInfos): array
Expand All @@ -24,6 +24,10 @@ public function filterAndJoinWithDependentFileInfos(array $fileInfos): array
$dependentFileInfos = [];

foreach ($fileInfos as $fileInfo) {
if (is_string($fileInfo)) {
$fileInfo = new SmartFileInfo($fileInfo);
}

if (! $this->changedFilesDetector->hasFileChanged($fileInfo)) {
continue;
}
Expand Down
7 changes: 1 addition & 6 deletions src/FileSystem/FilesFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,7 @@ public function findInDirectoriesAndFiles(array $source, array $suffixes = []):

$directories = $this->fileSystemFilter->filterDirectories($filesAndDirectories);

$smartFileInfos = [];
foreach ($filePaths as $filePath) {
$smartFileInfos[] = new SmartFileInfo($filePath);
}

$smartFileInfos = $this->unchangedFilesFilter->filterAndJoinWithDependentFileInfos($smartFileInfos);
$smartFileInfos = $this->unchangedFilesFilter->filterAndJoinWithDependentFileInfos($filePaths);

return array_merge($smartFileInfos, $this->findInDirectories($directories, $suffixes));
}
Expand Down

0 comments on commit c8b47df

Please sign in to comment.