Project

General

Profile

Actions

Task #54095

closed

Optimization of GeneralUtility::getFilesInDir()

Added by Michiel Roos over 10 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Performance
Target version:
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.


Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Task #56121: getFilesInDirCanOrderByMtime-test should use vfsClosedStefan Neufeind2014-02-19

Actions
Follows TYPO3 Core - Task #55762: getFilesInDir() needs unit testsClosed2014-02-07

Actions
Actions #1

Updated by Gerrit Code Review over 10 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25768

Actions #2

Updated by Gerrit Code Review about 10 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25768

Actions #4

Updated by Gerrit Code Review about 10 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25768

Actions #5

Updated by Gerrit Code Review about 10 years ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25768

Actions #6

Updated by Gerrit Code Review about 10 years ago

Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25768

Actions #7

Updated by Gerrit Code Review about 10 years ago

Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25768

Actions #8

Updated by Gerrit Code Review about 10 years ago

Patch set 7 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25768

Actions #9

Updated by Gerrit Code Review about 10 years ago

Patch set 8 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25768

Actions #10

Updated by Gerrit Code Review about 10 years ago

Patch set 9 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25768

Actions #11

Updated by Gerrit Code Review about 10 years ago

Patch set 10 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25768

Actions #12

Updated by Gerrit Code Review about 10 years ago

Patch set 11 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25768

Actions #13

Updated by Gerrit Code Review about 10 years ago

Patch set 12 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25768

Actions #14

Updated by Gerrit Code Review about 10 years ago

Patch set 13 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25768

Actions #15

Updated by Gerrit Code Review about 10 years ago

Patch set 14 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25768

Actions #16

Updated by Gerrit Code Review about 10 years ago

Patch set 15 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25768

Actions #17

Updated by Gerrit Code Review about 10 years ago

Patch set 16 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25768

Actions #18

Updated by Gerrit Code Review about 10 years ago

Patch set 17 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25768

Actions #19

Updated by Gerrit Code Review about 10 years ago

Patch set 18 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25768

Actions #20

Updated by Gerrit Code Review about 10 years ago

Patch set 19 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/25768

Actions #21

Updated by Michiel Roos about 10 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #22

Updated by Benni Mack over 5 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF