Skip to content

Commit e5bf0ab

Browse files
committed
Exclude files based on path before applying the sorting
Sorting can be slow, so it is best to applied it after all filtering rules are applied instead of using a bigger list and filtering again after that.
1 parent 47b17eb commit e5bf0ab

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Symfony/Component/Finder/Adapter/PhpAdapter.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ public function searchInDirectory($dir)
6868
$iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
6969
}
7070

71+
if ($this->paths || $this->notPaths) {
72+
$iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $this->notPaths);
73+
}
74+
7175
if ($this->sort) {
7276
$iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
7377
$iterator = $iteratorAggregate->getIterator();
7478
}
7579

76-
if ($this->paths || $this->notPaths) {
77-
$iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $this->notPaths);
78-
}
79-
8080
return $iterator;
8181
}
8282

0 commit comments

Comments
 (0)