From e5bf0ab8770458e592c096c7ce24a5b270cf5b0b Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Tue, 15 Sep 2015 11:15:55 +0200 Subject: [PATCH] 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. --- src/Symfony/Component/Finder/Adapter/PhpAdapter.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/Finder/Adapter/PhpAdapter.php b/src/Symfony/Component/Finder/Adapter/PhpAdapter.php index 378a26acda..d8c32dbb4f 100644 --- a/src/Symfony/Component/Finder/Adapter/PhpAdapter.php +++ b/src/Symfony/Component/Finder/Adapter/PhpAdapter.php @@ -68,15 +68,15 @@ class PhpAdapter extends AbstractAdapter $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters); } + if ($this->paths || $this->notPaths) { + $iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $this->notPaths); + } + if ($this->sort) { $iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort); $iterator = $iteratorAggregate->getIterator(); } - if ($this->paths || $this->notPaths) { - $iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $this->notPaths); - } - return $iterator; }