From f1b0045dd3764f9eb4093067525f87ab6dac67a7 Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Tue, 6 Dec 2022 10:32:27 -0800 Subject: [PATCH] Move from `count(...)` to `contains(...)` PiperOrigin-RevId: 493346962 --- src/google/protobuf/compiler/objectivec/generator.cc | 2 +- src/google/protobuf/compiler/objectivec/names.cc | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/google/protobuf/compiler/objectivec/generator.cc b/src/google/protobuf/compiler/objectivec/generator.cc index aeb4da880a..0983031847 100644 --- a/src/google/protobuf/compiler/objectivec/generator.cc +++ b/src/google/protobuf/compiler/objectivec/generator.cc @@ -303,7 +303,7 @@ bool ObjectiveCGenerator::GenerateAll( } // Generate m file. - if (!headers_only && skip_impls.count(file->name()) == 0) { + if (!headers_only && !skip_impls.contains(file->name())) { std::unique_ptr output( context->Open(filepath + ".pbobjc.m")); io::Printer printer(output.get(), '$'); diff --git a/src/google/protobuf/compiler/objectivec/names.cc b/src/google/protobuf/compiler/objectivec/names.cc index 2e1c45c4d0..a29656d23e 100644 --- a/src/google/protobuf/compiler/objectivec/names.cc +++ b/src/google/protobuf/compiler/objectivec/names.cc @@ -219,7 +219,7 @@ bool PrefixModeStorage::is_package_exempted(const std::string& package) { } } - return exceptions_.count(package) != 0; + return exceptions_.contains(package); } PrefixModeStorage& g_prefix_mode = *new PrefixModeStorage(); @@ -321,7 +321,7 @@ std::string UnderscoresToCamelCase(const std::string& input, std::string result; bool first_segment_forces_upper = false; for (auto& value : values) { - bool all_upper = (UpperSegments().count(value) > 0); + bool all_upper = UpperSegments().contains(value); if (all_upper && (result.length() == 0)) { first_segment_forces_upper = true; } @@ -583,9 +583,8 @@ std::string SanitizeNameForObjC(const std::string& prefix, } else { sanitized = prefix + input; } - if (IsReservedCIdentifier(sanitized) || - (ReservedWords().count(sanitized) > 0) || - (NSObjectMethods().count(sanitized) > 0)) { + if (IsReservedCIdentifier(sanitized) || ReservedWords().contains(sanitized) || + NSObjectMethods().contains(sanitized)) { if (out_suffix_added) *out_suffix_added = extension; return sanitized + extension; }