Speed up WriteKeepSet when generate_conditional_proguard_rules is off.
The results of CollectLocations() are only used if the --proguard-conditional-keep-rules option is set, but the function is always called when the --proguard option is set. Since this function can be slow on particularly large resource sets, avoid calling it unless --proguard-conditional-keep-rules is set. Change-Id: If259d41cdab16abad8ca62f30d8beb5ebf33575a Bug: 144236322 Test: aapt2_tests
This commit is contained in:
@@ -404,12 +404,15 @@ void WriteKeepSet(const KeepSet& keep_set, OutputStream* out, bool minimal_keep)
|
||||
|
||||
for (const auto& entry : keep_set.conditional_class_set_) {
|
||||
std::set<UsageLocation> locations;
|
||||
bool can_be_conditional = true;
|
||||
for (const UsageLocation& location : entry.second) {
|
||||
can_be_conditional &= CollectLocations(location, keep_set, &locations);
|
||||
bool can_be_conditional = false;
|
||||
if (keep_set.conditional_keep_rules_) {
|
||||
can_be_conditional = true;
|
||||
for (const UsageLocation& location : entry.second) {
|
||||
can_be_conditional &= CollectLocations(location, keep_set, &locations);
|
||||
}
|
||||
}
|
||||
|
||||
if (keep_set.conditional_keep_rules_ && can_be_conditional) {
|
||||
if (can_be_conditional) {
|
||||
for (const UsageLocation& location : locations) {
|
||||
printer.Print("# Referenced at ").Println(location.source.to_string());
|
||||
printer.Print("-if class **.R$layout { int ")
|
||||
|
||||
Reference in New Issue
Block a user