From a327a7f85cb88b575a189b2db92ec51d5614bdcb Mon Sep 17 00:00:00 2001 From: anth64 Date: Tue, 15 Sep 2026 12:56:27 +0200 Subject: [PATCH] perf: skip redundant mkdir_p in funpack for entries without subdirectories --- tools/funpack.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/funpack.c b/tools/funpack.c index ebaeda6..f17fc1b 100644 --- a/tools/funpack.c +++ b/tools/funpack.c @@ -126,19 +126,20 @@ static int extract_entry(const char *out_dir, const fpk_entry_t *entry, const void *data, size_t size) { char *full_path = join_path(out_dir, entry->path); - char *dir_part = dup_str(full_path); - char *slash = strrchr(dir_part, '/'); FILE *fp; - if (slash) { + if (strchr(entry->path, '/') != NULL) { + char *dir_part = dup_str(full_path); + char *slash = strrchr(dir_part, '/'); + *slash = '\0'; if (!mkdir_p(dir_part)) { free(dir_part); free(full_path); return 0; } + free(dir_part); } - free(dir_part); fp = fopen(full_path, "wb"); if (!fp) {