summaryrefslogtreecommitdiff
path: root/src/metaentry.c
diff options
context:
space:
mode:
authorAdam Spragg <adam@spra.gg>2022-07-07 13:57:37 +0100
committerAdam Spragg <adam@spra.gg>2022-07-08 08:36:43 +0100
commit2670293c68fe700a5320e3d37815091e3590d39a (patch)
treedafb7f749ac55789953d555a1c200eb55cadbffb /src/metaentry.c
parentb46002f1c47d7716fc582269e3d943b87bbdcf9c (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.c2
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);