Skip to content

Commit

Permalink
Rename external_id_roots (#908)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #908

I find it easier to understand this code if the variable names are more accurately describing what it is doing. It's parsing manifest files, so name it that way.

Reviewed By: thezhangwei

Differential Revision: D70333035

fbshipit-source-id: 5298b17849b1642384097b5074a6fd449a79b5ac
  • Loading branch information
wsanville authored and facebook-github-bot committed Mar 3, 2025
1 parent 5efe6cb commit 4d709f4
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions opt/optimize_resources/OptimizeResources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,18 +406,17 @@ void OptimizeResourcesPass::run_pass(DexStoresVector& stores,
// Set of ID's directly accessible from the manifest or anims XML files,
// without walking any reference chains.
std::unordered_set<std::string> explored_xml_files;
std::unordered_set<uint32_t> external_id_roots;
std::unordered_set<uint32_t> manifest_roots;
const auto& xml_files = resources->find_all_xml_files();
for (const std::string& path : xml_files) {
if (path.find("AndroidManifest.xml") == std::string::npos) {
continue;
}
explored_xml_files.emplace(path);
const auto& id_roots = resources->get_xml_reference_attributes(path);
external_id_roots.insert(id_roots.begin(), id_roots.end());
manifest_roots.insert(id_roots.begin(), id_roots.end());
}
TRACE(OPTRES, 2, "Total external_id_roots count: %zu",
external_id_roots.size());
TRACE(OPTRES, 2, "Total manifest_roots count: %zu", manifest_roots.size());

// 4. Get all resources referenced by custom frameworks and configuration
// options.
Expand Down Expand Up @@ -447,8 +446,7 @@ void OptimizeResourcesPass::run_pass(DexStoresVector& stores,
// 5. Merge above resources (2, 3 & 4). These will be the 'roots' of all
// referenced resources. Then, compute the transitive closure of all the
// roots. This will be the set of all referenced resources (to be kept).
accessible_id_roots.insert(external_id_roots.begin(),
external_id_roots.end());
accessible_id_roots.insert(manifest_roots.begin(), manifest_roots.end());
accessible_id_roots.insert(ids_from_code.begin(), ids_from_code.end());
accessible_id_roots.insert(assumed_reachable_roots.begin(),
assumed_reachable_roots.end());
Expand Down

0 comments on commit 4d709f4

Please sign in to comment.