9 ms·
You need not newfstatat every dirent unless you need more metadata (times, size, etc.) for something else (as alluded to above by, at least, both me and bscphil
by cb321 5y ago
You need not newfstatat every dirent unless you need more metadata (times, size, etc.) for something else (as alluded to above by, at least, both me and bscphil elsewhere in this thread). You can simply try to call `opendir()` based upon `d_type`. See [1].
IIRC, this d_type in dirent usage is somewhat new (maybe mid- to late- 1990s) compared to Unix itself. In olden times, one had to stat. It is possible the filesystem you are testing on gives DT_UNKNOWN all the time mandating stats. [2]
[1] https://lobste.rs/s/kpzdew/git_ls_files_is_faster_than_fd_find#c_nal5fc https://lobste.rs/s/kpzdew/git_ls_files_is_faster_than_fd_fi...
[2] https://stackoverflow.com/questions/47078417/readdir-returning-dirent-with-d-type-dt-unknown-for-directories-and https://stackoverflow.com/questions/47078417/readdir-returni...