[php-src] PR #11577: Fix GH-11573: RecursiveDirectoryIterator::hasChildren is slow
| From: | nielsdos | Date: | Sun, 02 Jul 2023 20:42:52 +0000 |
| Subject: | [php-src] PR #11577: Fix GH-11573: RecursiveDirectoryIterator::hasChildren is slow | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-22874@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/11577
Author: nielsdos
This PR does three things:
* Gets rid of an unused field
is_recursive
* Reduces the size of directory entries when NAME_MAX is defined. Previously, we used MAXPATHLEN,
which is the total path length, i.e. path + file name. Directory entries only contain a file name,
so we can use a smaller size. By doing so we spend less time allocating and clearing memory.
* We can avoid extra stat() calls by caching the d_type field from the directory entry. The last
commit adds a field d_type to _php_stream_dirent that will be filled in from the dirent. It also
does the necessary translation on Windows.
See https://github.com/php/php-src/issues/11573#issuecomment-1616790513
for results.