Clean up some warning messages.

- size vs empty
- unused decls
pull/7125/head
Dave MacLachlan 5 years ago committed by Thomas Van Lenten
parent ab48ecf140
commit e3c2af349f
  1. 16
      src/google/protobuf/compiler/objectivec/objectivec_helpers.cc
  2. 10
      src/google/protobuf/compiler/objectivec/objectivec_message.cc

@ -918,7 +918,7 @@ bool HasNonZeroDefaultValue(const FieldDescriptor* field) {
string BuildFlagsString(const FlagType flag_type, string BuildFlagsString(const FlagType flag_type,
const std::vector<string>& strings) { const std::vector<string>& strings) {
if (strings.size() == 0) { if (strings.empty()) {
return GetZeroEnumNameForFlagType(flag_type); return GetZeroEnumNameForFlagType(flag_type);
} else if (strings.size() == 1) { } else if (strings.size() == 1) {
return strings[0]; return strings[0];
@ -945,7 +945,7 @@ string BuildCommentsString(const SourceLocation& location,
lines.pop_back(); lines.pop_back();
} }
// If there are no comments, just return an empty string. // If there are no comments, just return an empty string.
if (lines.size() == 0) { if (lines.empty()) {
return ""; return "";
} }
@ -1405,7 +1405,7 @@ string DirectDecodeString(const string& str) {
// static // static
string TextFormatDecodeData::DecodeDataForString(const string& input_for_decode, string TextFormatDecodeData::DecodeDataForString(const string& input_for_decode,
const string& desired_output) { const string& desired_output) {
if ((input_for_decode.size() == 0) || (desired_output.size() == 0)) { if (input_for_decode.empty() || desired_output.empty()) {
std::cerr << "error: got empty string for making TextFormat data, input: \"" std::cerr << "error: got empty string for making TextFormat data, input: \""
<< input_for_decode << "\", desired: \"" << desired_output << "\"." << input_for_decode << "\", desired: \"" << desired_output << "\"."
<< std::endl; << std::endl;
@ -1515,7 +1515,7 @@ bool Parser::ParseLoop() {
++line_; ++line_;
RemoveComment(&line); RemoveComment(&line);
TrimWhitespace(&line); TrimWhitespace(&line);
if (line.size() == 0) { if (line.empty()) {
continue; // Blank line. continue; // Blank line.
} }
if (!line_consumer_->ConsumeLine(line, &error_str_)) { if (!line_consumer_->ConsumeLine(line, &error_str_)) {
@ -1622,7 +1622,7 @@ void ImportWriter::Print(io::Printer* printer) const {
bool add_blank_line = false; bool add_blank_line = false;
if (protobuf_framework_imports_.size() > 0) { if (!protobuf_framework_imports_.empty()) {
const string framework_name(ProtobufLibraryFrameworkName); const string framework_name(ProtobufLibraryFrameworkName);
const string cpp_symbol(ProtobufFrameworkImportSymbol(framework_name)); const string cpp_symbol(ProtobufFrameworkImportSymbol(framework_name));
@ -1650,7 +1650,7 @@ void ImportWriter::Print(io::Printer* printer) const {
add_blank_line = true; add_blank_line = true;
} }
if (other_framework_imports_.size() > 0) { if (!other_framework_imports_.empty()) {
if (add_blank_line) { if (add_blank_line) {
printer->Print("\n"); printer->Print("\n");
} }
@ -1665,7 +1665,7 @@ void ImportWriter::Print(io::Printer* printer) const {
add_blank_line = true; add_blank_line = true;
} }
if (other_imports_.size() > 0) { if (!other_imports_.empty()) {
if (add_blank_line) { if (add_blank_line) {
printer->Print("\n"); printer->Print("\n");
} }
@ -1717,7 +1717,7 @@ bool ImportWriter::ProtoFrameworkCollector::ConsumeLine(
StringPiece proto_file = proto_file_list.substr(start, offset - start); StringPiece proto_file = proto_file_list.substr(start, offset - start);
TrimWhitespace(&proto_file); TrimWhitespace(&proto_file);
if (proto_file.size() != 0) { if (!proto_file.empty()) {
std::map<string, string>::iterator existing_entry = std::map<string, string>::iterator existing_entry =
map_->find(string(proto_file)); map_->find(string(proto_file));
if (existing_entry != map_->end()) { if (existing_entry != map_->end()) {

@ -50,9 +50,6 @@ namespace protobuf {
namespace compiler { namespace compiler {
namespace objectivec { namespace objectivec {
using internal::WireFormat;
using internal::WireFormatLite;
namespace { namespace {
struct FieldOrderingByNumber { struct FieldOrderingByNumber {
inline bool operator()(const FieldDescriptor* a, inline bool operator()(const FieldDescriptor* a,
@ -417,6 +414,7 @@ void MessageGenerator::GenerateSource(io::Printer* printer) {
SortFieldsByStorageSize(descriptor_)); SortFieldsByStorageSize(descriptor_));
std::vector<const Descriptor::ExtensionRange*> sorted_extensions; std::vector<const Descriptor::ExtensionRange*> sorted_extensions;
sorted_extensions.reserve(descriptor_->extension_range_count());
for (int i = 0; i < descriptor_->extension_range_count(); ++i) { for (int i = 0; i < descriptor_->extension_range_count(); ++i) {
sorted_extensions.push_back(descriptor_->extension_range(i)); sorted_extensions.push_back(descriptor_->extension_range(i));
} }
@ -536,7 +534,7 @@ void MessageGenerator::GenerateSource(io::Printer* printer) {
" fieldCount:$fields_count$\n" " fieldCount:$fields_count$\n"
" storageSize:sizeof($classname$__storage_)\n" " storageSize:sizeof($classname$__storage_)\n"
" flags:$init_flags$];\n"); " flags:$init_flags$];\n");
if (oneof_generators_.size() != 0) { if (!oneof_generators_.empty()) {
printer->Print( printer->Print(
" static const char *oneofs[] = {\n"); " static const char *oneofs[] = {\n");
for (const auto& generator : oneof_generators_) { for (const auto& generator : oneof_generators_) {
@ -567,7 +565,7 @@ void MessageGenerator::GenerateSource(io::Printer* printer) {
" [localDescriptor setupExtraTextInfo:extraTextFormatInfo];\n" " [localDescriptor setupExtraTextInfo:extraTextFormatInfo];\n"
"#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS\n"); "#endif // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS\n");
} }
if (sorted_extensions.size() != 0) { if (!sorted_extensions.empty()) {
printer->Print( printer->Print(
" static const GPBExtensionRange ranges[] = {\n"); " static const GPBExtensionRange ranges[] = {\n");
for (int i = 0; i < sorted_extensions.size(); i++) { for (int i = 0; i < sorted_extensions.size(); i++) {
@ -589,7 +587,7 @@ void MessageGenerator::GenerateSource(io::Printer* printer) {
} }
string suffix_added; string suffix_added;
ClassName(descriptor_, &suffix_added); ClassName(descriptor_, &suffix_added);
if (suffix_added.size() > 0) { if (!suffix_added.empty()) {
printer->Print( printer->Print(
" [localDescriptor setupMessageClassNameSuffix:@\"$suffix$\"];\n", " [localDescriptor setupMessageClassNameSuffix:@\"$suffix$\"];\n",
"suffix", suffix_added); "suffix", suffix_added);

Loading…
Cancel
Save