Switch from using count to contains and use heterogenous lookup where available

PiperOrigin-RevId: 493053915
pull/11140/head
Matt Kulukundis 2 years ago committed by Copybara-Service
parent 09cfed19e7
commit bc441c9892
  1. 10
      src/google/protobuf/descriptor.cc

@ -2357,9 +2357,9 @@ bool DescriptorPool::TryFindFileInFallbackDatabase(
absl::string_view name) const {
if (fallback_database_ == nullptr) return false;
auto name_string = std::string(name);
if (tables_->known_bad_files_.count(name_string) > 0) return false;
if (tables_->known_bad_files_.contains(name)) return false;
std::string name_string(name);
FileDescriptorProto file_proto;
if (!fallback_database_->FindFileByName(name_string, &file_proto) ||
BuildFileFromDatabase(file_proto) == nullptr) {
@ -2395,9 +2395,9 @@ bool DescriptorPool::TryFindSymbolInFallbackDatabase(
absl::string_view name) const {
if (fallback_database_ == nullptr) return false;
auto name_string = std::string(name);
if (tables_->known_bad_symbols_.count(name_string) > 0) return false;
if (tables_->known_bad_symbols_.contains(name)) return false;
std::string name_string(name);
FileDescriptorProto file_proto;
if ( // We skip looking in the fallback database if the name is a sub-symbol
// of any descriptor that already exists in the descriptor pool (except
@ -4119,7 +4119,7 @@ const FileDescriptor* DescriptorPool::BuildFileCollectingErrors(
const FileDescriptor* DescriptorPool::BuildFileFromDatabase(
const FileDescriptorProto& proto) const {
mutex_->AssertHeld();
if (tables_->known_bad_files_.count(proto.name()) > 0) {
if (tables_->known_bad_files_.contains(proto.name())) {
return nullptr;
}
const FileDescriptor* result =

Loading…
Cancel
Save