From f1bd1fef7cec32f640d9f36aca21ac685d5efa15 Mon Sep 17 00:00:00 2001 From: Thomas Bertschinger Date: Mon, 9 Dec 2024 19:35:35 -0700 Subject: [PATCH] remove embedded `struct stat` to make `struct BottomUp` smaller The embedded `struct stat` is only used to check the dirent's type to decide how to process it. It isn't later checked, so there's no need to store it. This reduces the size of `struct BottomUp` to 184 bytes. --- include/BottomUp.h | 1 - src/BottomUp.c | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/BottomUp.h b/include/BottomUp.h index e4eb35d7a..4b7d0277c 100644 --- a/include/BottomUp.h +++ b/include/BottomUp.h @@ -102,7 +102,6 @@ struct BottomUp { size_t name_len; char *alt_name; size_t alt_name_len; - struct stat st; struct { pthread_mutex_t mutex; size_t remaining; diff --git a/src/BottomUp.c b/src/BottomUp.c index eb3f22f46..3f4a2a613 100644 --- a/src/BottomUp.c +++ b/src/BottomUp.c @@ -337,7 +337,8 @@ static int descend_to_bottom(QPTPool_t *ctx, const size_t id, void *data, void * } timestamp_create_start(lstat_entry); - const int rc = lstat(new_work.name, &new_work.st); + struct stat st; + const int rc = lstat(new_work.name, &st); timestamp_end_print(ua->timestamp_buffers, id, "lstat", lstat_entry); if (rc != 0) { @@ -346,7 +347,7 @@ static int descend_to_bottom(QPTPool_t *ctx, const size_t id, void *data, void * } timestamp_create_start(track_entry); - if (S_ISDIR(new_work.st.st_mode)) { + if (S_ISDIR(st.st_mode)) { track(&new_work, ua->user_struct_size, &bu->subdirs, next_level, ua->generate_alt_name);