Attached is a patch that can greatly improve the performance of directory-files-and-attributes, which I'd like to install into the trunk. The key idea is to use fstatat instead of lstat; this reduces directory-reading from an O(ND) to an O(N) operation, where N is the number of directory entries and D is the length of the directory's name. This patch works on POSIXish hosts, but it'll no doubt need a few changes to the MS-Windows makefiles to compile fdopendir.c, fstatat.c, openat-die.c, save-cwd.c, openat-proc.c, or whatever subset of these is needed on MS-Windows. I'll CC: this to Eli to give him a heads-up. This patch is relative to trunk bzr 111595.