Pass dir_name by reference

Passing dir_name by reference will save a copy constructor.
This commit is contained in:
Nemirtingas 2019-06-19 18:39:14 +02:00
parent 717808e796
commit a1d336bf56

View file

@ -218,7 +218,7 @@ static std::vector<struct File_Data> get_filenames_recursive(std::string base_pa
std::vector<struct File_Data> lower = get_filenames_recursive(path); std::vector<struct File_Data> lower = get_filenames_recursive(path);
output.push_back(File_Data{ dir_name });// Is this needed ? Add folder name to the list of files ? output.push_back(File_Data{ dir_name });// Is this needed ? Add folder name to the list of files ?
std::transform(lower.begin(), lower.end(), std::back_inserter(output), [dir_name](File_Data f) {f.name = dir_name + "\\" + f.name; return f;}); std::transform(lower.begin(), lower.end(), std::back_inserter(output), [&dir_name](File_Data f) {f.name = dir_name + "\\" + f.name; return f;});
} else { } else {
File_Data f; File_Data f;
f.name = ffd.cFileName; f.name = ffd.cFileName;
@ -357,7 +357,7 @@ static std::vector<struct File_Data> get_filenames_recursive(std::string base_pa
path += dir_name; path += dir_name;
std::vector<struct File_Data> lower = get_filenames_recursive(path); std::vector<struct File_Data> lower = get_filenames_recursive(path);
std::transform(lower.begin(), lower.end(), std::back_inserter(output), [dir_name](File_Data f) {f.name = dir_name + "/" + f.name; return f;}); std::transform(lower.begin(), lower.end(), std::back_inserter(output), [&dir_name](File_Data f) {f.name = dir_name + "/" + f.name; return f;});
} }
} }
} }