perf: Task加载检查前重复任务

This commit is contained in:
status102
2025-04-27 23:35:49 +08:00
parent 63e801350f
commit d044e79ebc

View File

@@ -222,7 +222,7 @@ bool asst::TaskData::load(const std::filesystem::path& path)
{
LogTraceScope("TaskData::load");
json::value merged = json::object();
json::object merged;
if (is_regular_file(path)) {
Log.debug("TaskData::load", "Loading json file:", path);
@@ -231,7 +231,7 @@ bool asst::TaskData::load(const std::filesystem::path& path)
Log.error("TaskData::load", "Json open failed:", path);
return false;
}
merged = ret.value();
merged = ret->as_object();
}
else if (is_directory(path)) {
std::vector<std::filesystem::path> json_files;
@@ -253,7 +253,10 @@ bool asst::TaskData::load(const std::filesystem::path& path)
continue;
}
for (auto& [key, value] : file_json.as_object()) {
merged.as_object()[key] = std::move(value);
if (!merged.emplace(key, std::move(value)).second) {
Log.error(__FUNCTION__, "Duplicate key in json file:", file, key);
return false;
}
}
}
}