diff options
author | Adam Spragg <adam@spra.gg> | 2022-07-07 18:52:15 +0100 |
---|---|---|
committer | Adam Spragg <adam@spra.gg> | 2022-07-08 08:36:47 +0100 |
commit | 15f76771009d78fbe6f8f9715080436ad9d92a68 (patch) | |
tree | 639c0bff2c41dd803b1ca105ddd3a2eee4fb1cc1 | |
parent | 2670293c68fe700a5320e3d37815091e3590d39a (diff) |
Check for directories with the mode stored in the mentryperf-2
Saves one call to lstat(2) per file.
On my system, this improves `time bin/metastore -d /usr >/dev/null` from:
real 0m2.183s
user 0m0.733s
sys 0m1.435s
to:
real 0m1.846s
user 0m0.663s
sys 0m1.134s
Average of 5 runs, on a warm cache, reducing runtime by roughly 15%.
-rw-r--r-- | src/metaentry.c | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/src/metaentry.c b/src/metaentry.c index 146fcf9..94167e7 100644 --- a/src/metaentry.c +++ b/src/metaentry.c @@ -351,7 +351,6 @@ normalize_path(const char *orig) static void mentries_recurse(const char *path, struct metahash *mhash, msettings *st) { - struct stat sbuf; struct metaentry *mentry; char tpath[PATH_MAX]; DIR *dir; @@ -360,19 +359,13 @@ mentries_recurse(const char *path, struct metahash *mhash, msettings *st) if (!path) return; - if (lstat(path, &sbuf)) { - msg(MSG_ERROR, "lstat failed for %s: %s\n", - path, strerror(errno)); - return; - } - mentry = mentry_create(path); if (!mentry) return; mentry_insert(mentry, mhash); - if (S_ISDIR(sbuf.st_mode)) { + if (S_ISDIR(mentry->mode)) { dir = opendir(path); if (!dir) { msg(MSG_ERROR, "opendir failed for %s: %s\n", |