Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 7f663a4d9b7248dc94fd3e36548dcafa1de590d4
      
https://github.com/WebKit/WebKit/commit/7f663a4d9b7248dc94fd3e36548dcafa1de590d4
  Author: Chris Dumez <[email protected]>
  Date:   2026-04-29 (Wed, 29 Apr 2026)

  Changed paths:
    M Source/WTF/wtf/FileSystem.cpp
    M Source/WTF/wtf/FileSystem.h
    M Source/WTF/wtf/playstation/FileSystemPlayStation.cpp
    M Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp
    M Source/WebCore/html/DirectoryFileListCreator.cpp
    M Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.cpp

  Log Message:
  -----------
  Add FileSystem::traverseDirectory() to avoid redundant lstat() per directory 
entry
https://bugs.webkit.org/show_bug.cgi?id=313538

Reviewed by Darin Adler.

FileSystem::listDirectory() uses std::filesystem::directory_iterator internally,
which caches each entry's file type from readdir's d_type field. However, it 
only
returns filenames, discarding the cached type. Callers that need the entry type
then call FileSystem::fileType() per entry, which does a redundant lstat() 
syscall
to rediscover what directory_iterator already knew.

Add FileSystem::traverseDirectory() that uses directory_iterator directly and
provides both the filename and file type to the callback, reading the type from
directory_entry::symlink_status() which uses the cached d_type without a 
syscall.
It also avoids materializing all filenames into an intermediate Vector.

Update the four call sites that were doing listDirectory() + fileType() per 
entry:
NetworkCacheFileSystem, deleteAllFilesModifiedSince, DirectoryFileListCreator,
and DOMFileSystem::listDirectoryWithMetadata.

* Source/WTF/wtf/FileSystem.cpp:
(WTF::FileSystemImpl::deleteAllFilesModifiedSince):
(WTF::FileSystemImpl::traverseDirectory):
* Source/WTF/wtf/FileSystem.h:
* Source/WTF/wtf/playstation/FileSystemPlayStation.cpp:
(WTF::FileSystemImpl::traverseDirectory):
* Source/WebCore/Modules/entriesapi/DOMFileSystem.cpp:
(WebCore::listDirectoryWithMetadata):
* Source/WebCore/html/DirectoryFileListCreator.cpp:
(WebCore::appendDirectoryFiles):
* Source/WebKit/NetworkProcess/cache/NetworkCacheFileSystem.cpp:
(WebKit::NetworkCache::traverseDirectory):

Canonical link: https://commits.webkit.org/312267@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to