Skip to content

Commit 1f01875

Browse files
committed
opt files iteration
1 parent c75524b commit 1f01875

File tree

1 file changed

+14
-22
lines changed

1 file changed

+14
-22
lines changed

src/core/bundled_folder_manager.cpp

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,38 +1006,30 @@ VxCoreError BundledFolderManager::CopyFile(const std::string &src_file_path,
10061006

10071007
void BundledFolderManager::IterateAllFiles(
10081008
std::function<bool(const std::string &, const FileRecord &)> callback) {
1009-
std::vector<std::string> folder_paths;
1010-
1011-
std::function<void(const std::string &)> collect_folders = [&](const std::string &fp) {
1012-
folder_paths.push_back(fp);
1013-
1009+
std::function<bool(const std::string &)> iterate_folder = [&](const std::string &fp) {
10141010
FolderConfig *config = nullptr;
10151011
VxCoreError error = GetFolderConfig(fp, &config);
10161012
if (error != VXCORE_OK) {
1017-
return;
1013+
return true;
1014+
}
1015+
1016+
for (const auto &file : config->files) {
1017+
if (!callback(fp, file)) {
1018+
return false;
1019+
}
10181020
}
10191021

10201022
for (const auto &folder_name : config->folders) {
10211023
std::string child_path = fp.empty() ? folder_name : fp + "/" + folder_name;
1022-
collect_folders(child_path);
1024+
if (!iterate_folder(child_path)) {
1025+
return false;
1026+
}
10231027
}
1024-
};
1025-
1026-
collect_folders("");
10271028

1028-
for (const auto &fp : folder_paths) {
1029-
FolderConfig *config = nullptr;
1030-
VxCoreError error = GetFolderConfig(fp, &config);
1031-
if (error != VXCORE_OK) {
1032-
continue;
1033-
}
1029+
return true;
1030+
};
10341031

1035-
for (const auto &file : config->files) {
1036-
if (!callback(fp, file)) {
1037-
return;
1038-
}
1039-
}
1040-
}
1032+
iterate_folder(".");
10411033
}
10421034

10431035
VxCoreError BundledFolderManager::FindFilesByTag(const std::string &tag_name,

0 commit comments

Comments
 (0)