Skip to content

Commit

Permalink
remove embedded struct stat to make struct BottomUp smaller
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bertschinger committed Dec 10, 2024
1 parent 14bada6 commit f1bd1fe
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
1 change: 0 additions & 1 deletion include/BottomUp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/BottomUp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
Expand Down

0 comments on commit f1bd1fe

Please sign in to comment.