sh: Use dirent.d_type in pathname generation.

This improves performance for globs where a slash or another component
follows a component with metacharacters by eliminating unnecessary attempts
to open directories that are not.
This commit is contained in:
Jilles Tjoelker 2011-12-28 23:40:46 +00:00
parent 7a2b9d4b38
commit 6e8db49a44

View File

@ -1292,6 +1292,10 @@ expmeta(char *enddir, char *name)
if (atend)
addfname(expdir);
else {
if (dp->d_type != DT_UNKNOWN &&
dp->d_type != DT_DIR &&
dp->d_type != DT_LNK)
continue;
if (enddir + namlen + 2 > expdir_end)
continue;
enddir[namlen] = '/';