Bug 1875036 - Speed up directory enumeration on Windows. r=win-reviewers,gstoll

We replace the use of FindFirstFileW by FindFirstFileExW with the most
optimized combination of flags on the code path reached from
nsIDirectoryEnumerator on Windows. This should make enumeration faster,
in particular when enumerating directories with thousands of files like
it can happen in QuotaManager code.

Differential Revision: https://phabricator.services.mozilla.com/D207151
This commit is contained in:
Yannis Juglaret 2024-04-11 06:52:03 +00:00
Родитель 7c5cdb53a9
Коммит 484214561b
1 изменённых файлов: 4 добавлений и 2 удалений

Просмотреть файл

@ -673,10 +673,12 @@ static nsresult OpenDir(const nsString& aName, nsDir** aDir) {
filename.ReplaceChar(L'/', L'\\');
// FindFirstFileW Will have a last error of ERROR_DIRECTORY if
// FindFirstFileExW Will have a last error of ERROR_DIRECTORY if
// <file_path>\* is passed in. If <unknown_path>\* is passed in then
// ERROR_PATH_NOT_FOUND will be the last error.
d->handle = ::FindFirstFileW(filename.get(), &(d->data));
d->handle = ::FindFirstFileExW(filename.get(), FindExInfoBasic, &(d->data),
FindExSearchNameMatch, nullptr,
FIND_FIRST_EX_LARGE_FETCH);
if (d->handle == INVALID_HANDLE_VALUE) {
delete d;