Internal change

PiperOrigin-RevId: 485075266
pull/10846/head
Protobuf Team Bot 2 years ago committed by Joshua Haberman
parent 0115668cf3
commit 8aacf87f19
  1. 16
      src/google/protobuf/compiler/objectivec/file.cc
  2. 6
      src/google/protobuf/compiler/objectivec/file.h

@ -151,7 +151,7 @@ FileGenerator::CommonState::CollectMinimalFileDepsContainingExtensionsInternal(
} }
absl::flat_hash_set<const FileDescriptor*> min_deps_collector; absl::flat_hash_set<const FileDescriptor*> min_deps_collector;
absl::flat_hash_set<const FileDescriptor*> covered_deps_collector; absl::flat_hash_set<const FileDescriptor*> transitive_deps_collector;
absl::flat_hash_set<const FileDescriptor*> to_prune; absl::flat_hash_set<const FileDescriptor*> to_prune;
for (int i = 0; i < file->dependency_count(); i++) { for (int i = 0; i < file->dependency_count(); i++) {
const FileDescriptor* dep = file->dependency(i); const FileDescriptor* dep = file->dependency(i);
@ -159,11 +159,12 @@ FileGenerator::CommonState::CollectMinimalFileDepsContainingExtensionsInternal(
CollectMinimalFileDepsContainingExtensionsInternal(dep); CollectMinimalFileDepsContainingExtensionsInternal(dep);
// Everything the dep covered, this file will also cover. // Everything the dep covered, this file will also cover.
covered_deps_collector.insert(dep_info.covered_deps.begin(), transitive_deps_collector.insert(dep_info.transitive_deps.begin(),
dep_info.covered_deps.end()); dep_info.transitive_deps.end());
// Prune everything from the dep's covered list in case another dep lists it // Prune everything from the dep's covered list in case another dep lists it
// as a min dep. // as a min dep.
to_prune.insert(dep_info.covered_deps.begin(), dep_info.covered_deps.end()); to_prune.insert(dep_info.transitive_deps.begin(),
dep_info.transitive_deps.end());
// Does the dep have any extensions... // Does the dep have any extensions...
if (dep_info.has_extensions) { if (dep_info.has_extensions) {
@ -171,7 +172,7 @@ FileGenerator::CommonState::CollectMinimalFileDepsContainingExtensionsInternal(
// deps. // deps.
min_deps_collector.insert(dep); min_deps_collector.insert(dep);
to_prune.insert(dep_info.min_deps.begin(), dep_info.min_deps.end()); to_prune.insert(dep_info.min_deps.begin(), dep_info.min_deps.end());
covered_deps_collector.insert(dep_info.min_deps.begin(), transitive_deps_collector.insert(dep_info.min_deps.begin(),
dep_info.min_deps.end()); dep_info.min_deps.end());
} else { } else {
// No -> Just use its min_deps. // No -> Just use its min_deps.
@ -187,7 +188,8 @@ FileGenerator::CommonState::CollectMinimalFileDepsContainingExtensionsInternal(
if (to_prune.empty() || file->dependency_count() == 1) { if (to_prune.empty() || file->dependency_count() == 1) {
return deps_info_cache return deps_info_cache
.insert( .insert(
{file, {file_has_exts, min_deps_collector, covered_deps_collector}}) {file,
{file_has_exts, min_deps_collector, transitive_deps_collector}})
.first->second; .first->second;
} }
@ -198,7 +200,7 @@ FileGenerator::CommonState::CollectMinimalFileDepsContainingExtensionsInternal(
return to_prune.find(value) == to_prune.end(); return to_prune.find(value) == to_prune.end();
}); });
return deps_info_cache return deps_info_cache
.insert({file, {file_has_exts, min_deps, covered_deps_collector}}) .insert({file, {file_has_exts, min_deps, transitive_deps_collector}})
.first->second; .first->second;
} }

@ -62,10 +62,10 @@ class FileGenerator {
private: private:
struct MinDepsEntry { struct MinDepsEntry {
bool has_extensions; bool has_extensions;
// The minimal dependencies that cover all the dependencies with
// extensions.
absl::flat_hash_set<const FileDescriptor*> min_deps; absl::flat_hash_set<const FileDescriptor*> min_deps;
// `covered_deps` are the transtive deps of `min_deps_w_exts` that also absl::flat_hash_set<const FileDescriptor*> transitive_deps;
// have extensions.
absl::flat_hash_set<const FileDescriptor*> covered_deps;
}; };
const MinDepsEntry& CollectMinimalFileDepsContainingExtensionsInternal( const MinDepsEntry& CollectMinimalFileDepsContainingExtensionsInternal(
const FileDescriptor* file); const FileDescriptor* file);

Loading…
Cancel
Save