From 666f17d12f4aa30dc41a456157647bbe97dc5c99 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Sun, 18 Mar 2018 22:24:21 +0000 Subject: win32: don't test DLLs for executable format Moving detection of file formats from access(2) to stat(2) in commit 650f67507 was acknowledged to slow down stat. One problematic case is c:/windows/system32 which contains about 2000 DLLs and was found to slow 'ls' unacceptably. Treat DLLs as a special case in has_exec_format. See GitHub issue #101. --- win32/mingw.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'win32') diff --git a/win32/mingw.c b/win32/mingw.c index 112b2a54e..9978baa7a 100644 --- a/win32/mingw.c +++ b/win32/mingw.c @@ -330,6 +330,11 @@ static int has_exec_format(const char *name) unsigned int offset; unsigned char buf[1024]; + /* special case: skip DLLs, there are thousands of them! */ + n = strlen(name); + if (n > 4 && !strcasecmp(name+n-4, ".dll")) + return 0; + fd = open(name, O_RDONLY); if (fd < 0) return 0; -- cgit v1.2.3-55-g6feb