Update iterator and merge rid/non-rid assets

This commit is contained in:
Senthil 2016-03-15 13:23:11 -07:00
parent 2ce679c57d
commit 967fc370a0

View file

@ -139,9 +139,14 @@ bool deps_json_t::perform_rid_fallback(rid_specific_assets_t* portable_assets, c
assert(!matched_rid.empty()); assert(!matched_rid.empty());
for (auto iter = package.second.begin(); iter != package.second.end(); /* */) for (auto iter = package.second.begin(); iter != package.second.end(); /* */)
{ {
iter = (iter->first != matched_rid) if (iter->first != matched_rid)
? package.second.erase(iter) {
: iter++; iter = package.second.erase(iter);
}
else
{
++iter;
}
} }
} }
return true; return true;
@ -221,13 +226,27 @@ bool deps_json_t::load_portable(const json_value& json, const pal::string_t& tar
return false; return false;
} }
std::vector<pal::string_t> merged;
auto package_exists = [&rid_assets, &non_rid_assets](const pal::string_t& package) -> bool { auto package_exists = [&rid_assets, &non_rid_assets](const pal::string_t& package) -> bool {
return rid_assets.count(package) || non_rid_assets.count(package); return rid_assets.count(package) || non_rid_assets.count(package);
}; };
auto get_relpaths = [&rid_assets, &non_rid_assets](const pal::string_t& package, int type_index) -> const std::vector<pal::string_t>& { auto get_relpaths = [&rid_assets, &non_rid_assets, &merged](const pal::string_t& package, int type_index) -> const std::vector<pal::string_t>& {
return (rid_assets.count(package)) if (rid_assets.count(package) && non_rid_assets.count(package))
? rid_assets[package].begin()->second[type_index] {
: non_rid_assets[package][type_index]; const std::vector<pal::string_t>& rel1 = rid_assets[package].begin()->second[type_index];
const std::vector<pal::string_t>& rel2 = non_rid_assets[package][type_index];
merged.clear();
merged.reserve(rel1.size() + rel2.size());
merged.insert(merged.end(), rel1.begin(), rel1.end());
merged.insert(merged.end(), rel2.begin(), rel2.end());
return merged;
}
else
{
return rid_assets.count(package)
? rid_assets[package].begin()->second[type_index]
: non_rid_assets[package][type_index];
}
}; };
reconcile_libraries_with_targets(json, package_exists, get_relpaths); reconcile_libraries_with_targets(json, package_exists, get_relpaths);