Skip to content

Commit

Permalink
Clean up some warnings
Browse files Browse the repository at this point in the history
Move to explicit on single arg c'tors.
Move to unordered container types when working with pointers as order is likely unnecessary and just a performance issue.
  • Loading branch information
dmaclach authored and thomasvl committed Jun 9, 2022
1 parent 0a16bdf commit 922f502
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/google/protobuf/compiler/objectivec/objectivec_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ FileGenerator::CommonState::CollectMinimalFileDepsContainingExtensionsInternal(
return it->second;
}

std::set<const FileDescriptor*> min_deps_collector;
std::set<const FileDescriptor*> covered_deps_collector;
std::set<const FileDescriptor*> to_prune;
std::unordered_set<const FileDescriptor*> min_deps_collector;
std::unordered_set<const FileDescriptor*> covered_deps_collector;
std::unordered_set<const FileDescriptor*> to_prune;
for (int i = 0; i < file->dependency_count(); i++) {
const FileDescriptor* dep = file->dependency(i);
MinDepsEntry dep_info =
Expand Down Expand Up @@ -180,7 +180,7 @@ FileGenerator::CommonState::CollectMinimalFileDepsContainingExtensionsInternal(
{file, {file_has_exts, min_deps_collector, covered_deps_collector}}).first->second;
}

std::set<const FileDescriptor*> min_deps;
std::unordered_set<const FileDescriptor*> min_deps;
std::copy_if(min_deps_collector.begin(), min_deps_collector.end(),
std::inserter(min_deps, min_deps.end()),
[&](const FileDescriptor* value){
Expand All @@ -202,7 +202,7 @@ FileGenerator::CommonState::CollectMinimalFileDepsContainingExtensionsInternal(
const std::vector<const FileDescriptor*>
FileGenerator::CommonState::CollectMinimalFileDepsContainingExtensions(
const FileDescriptor* file) {
std::set<const FileDescriptor*> min_deps =
std::unordered_set<const FileDescriptor*> min_deps =
CollectMinimalFileDepsContainingExtensionsInternal(file).min_deps;
// Sort the list since pointer order isn't stable across runs.
std::vector<const FileDescriptor*> result(min_deps.begin(), min_deps.end());
Expand Down
6 changes: 3 additions & 3 deletions src/google/protobuf/compiler/objectivec/objectivec_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ class FileGenerator {
private:
struct MinDepsEntry {
bool has_extensions;
std::set<const FileDescriptor*> min_deps;
std::unordered_set<const FileDescriptor*> min_deps;
// `covered_deps` are the transtive deps of `min_deps_w_exts` that also
// have extensions.
std::set<const FileDescriptor*> covered_deps;
std::unordered_set<const FileDescriptor*> covered_deps;
};
const MinDepsEntry& CollectMinimalFileDepsContainingExtensionsInternal(const FileDescriptor* file);
std::map<const FileDescriptor*, MinDepsEntry> deps_info_cache_;
std::unordered_map<const FileDescriptor*, MinDepsEntry> deps_info_cache_;
};

FileGenerator(const FileDescriptor* file,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ bool BoolFromEnvVar(const char* env_var, bool default_value) {

class SimpleLineCollector : public LineConsumer {
public:
SimpleLineCollector(std::unordered_set<std::string>* inout_set)
explicit SimpleLineCollector(std::unordered_set<std::string>* inout_set)
: set_(inout_set) {}

virtual bool ConsumeLine(const StringPiece& line, std::string* out_error) override {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ TEST(ObjCHelperDeathTest, TextFormatDecodeData_Failures) {

class TestLineCollector : public LineConsumer {
public:
TestLineCollector(std::vector<std::string>* inout_lines,
explicit TestLineCollector(std::vector<std::string>* inout_lines,
const std::string* reject_line = nullptr,
bool skip_msg = false)
: lines_(inout_lines), reject_(reject_line), skip_msg_(skip_msg) {}
Expand Down

0 comments on commit 922f502

Please sign in to comment.