Actions
Task #54095
closedOptimization of GeneralUtility::getFilesInDir()
Start date:
2014-02-08
Due date:
2014-02-08
% Done:
100%
Estimated time:
TYPO3 Version:
6.1
PHP Version:
5.3
Tags:
Complexity:
easy
Sprint Focus:
Description
- The current getFilesInDir calls strlen($extensionList) and strlen($excludePattern) in a while loop. These values are unchanging and should be calculated only once outside of the loop.
- From the data provided by the pathinfo($entry) call, only the extension is used. This can be written as: pathinfo($entry, PATHINFO_EXTENSION) which returns a simple string.
- The if condition: $prependPath ? $path . '/' : '' can be rewritten to use a variable variable.
But upon further inspection, it turns out that dropping the dir->read() in favor of glob() saves a lot of time.
Test results are here:We can save even more time by dropping the is_file() check from the glob() version. We search for files matching .ext. If no ext is given this will become *.. So false positives (directories instead of files) may be found if the searched directory contains directories ending in a dot followed by one of the extensions searched for or a dot (in case *.* is searched). So I'll submit a patch that does use the is_file() check.
Also, the md5 takes time . . . but is needed for backwards compatibility.
Actions