From 0ea4ce92f4f4939242e19086956e9de9250adf3f Mon Sep 17 00:00:00 2001 From: AustrianToast Date: Wed, 14 Feb 2024 22:48:05 +0100 Subject: [PATCH] now less stupid executing two functions seemed smart before I knew the implementation but now it seems really stupid --- src/fs_reader.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/fs_reader.cpp b/src/fs_reader.cpp index 2ebb5df..1e1ceba 100644 --- a/src/fs_reader.cpp +++ b/src/fs_reader.cpp @@ -35,13 +35,12 @@ std::vector find_all_folders(std::string filesystem_path) { } std::vector find_all_files_and_folders(std::string filesystem_path) { - std::vector files = find_all_files(filesystem_path); - std::vector folders = find_all_folders(filesystem_path); std::vector files_and_folders = {}; - files_and_folders.reserve(files.size() + folders.size()); - files_and_folders.insert( files_and_folders.end(), files.begin(), files.end() ); - files_and_folders.insert( files_and_folders.end(), folders.begin(), folders.end() ); + for (const fs::directory_entry &entry : fs::directory_iterator(filesystem_path)) { + files_and_folders.insert(files_and_folders.begin()+files_and_folders.size(), entry.path()); + } + files_and_folders.shrink_to_fit(); return files_and_folders; }