[php-src] Issue #11573: `RecursiveDirectoryIterator::hasChildren` is slow

From: Date: Sat, 01 Jul 2023 22:11:45 +0000
Subject: [php-src] Issue #11573: `RecursiveDirectoryIterator::hasChildren` is slow
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-244862@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/11573
Author: mvorisek

### Description

![image](https://github.com/php/php-src/assets/2228672/ef4626da-000f-4b3e-959e-862813a07455)

I belive the currently php-src impl. checks if any iterated item has children on each
RecursiveDirectoryIterator::hasChildren call. This is slow.

I propose to cache the scanned files list with a file flag. If a current item is a file, it cannot
have children and it will optimize typical usecase - directory with many regular files.


Thread (1 message)

  • mvorisek
« previous php.bugs (#244862) next »