diff options
author | Adam Spragg <adam@spra.gg> | 2022-07-07 13:57:37 +0100 |
---|---|---|
committer | Adam Spragg <adam@spra.gg> | 2022-07-08 08:36:43 +0100 |
commit | 2670293c68fe700a5320e3d37815091e3590d39a (patch) | |
tree | dafb7f749ac55789953d555a1c200eb55cadbffb /src/metaentry.c | |
parent | b46002f1c47d7716fc582269e3d943b87bbdcf9c (diff) |
Return early if there are no xattrs
Saves one malloc(3) and one listxattr(2) per file that has no xattrs.
On my system, this improves `time metastore -d /usr >/dev/null` from:
real 0m2.347s
user 0m0.732s
sys 0m1.603s
to:
real 0m2.183s
user 0m0.733s
sys 0m1.435s
Average of 5 runs, on a warm cache, reducing runtime by roughly 7%.
Diffstat (limited to 'src/metaentry.c')
-rw-r--r-- | src/metaentry.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/metaentry.c b/src/metaentry.c index fe1c6d1..146fcf9 100644 --- a/src/metaentry.c +++ b/src/metaentry.c @@ -251,6 +251,8 @@ mentry_create(const char *path) path, strerror(errno)); return NULL; } + if (lsize == 0) + return mentry; list = xmalloc(lsize); lsize = listxattr(path, list, lsize); |