Merge "upkeep: Use empty() rather than size() == 0"
diff --git a/src/perfetto_cmd/config.cc b/src/perfetto_cmd/config.cc
index e51dc80..27e7a4c 100644
--- a/src/perfetto_cmd/config.cc
+++ b/src/perfetto_cmd/config.cc
@@ -31,7 +31,7 @@
 
 bool SplitValueAndUnit(const std::string& arg, ValueUnit* out) {
   char* end;
-  if (!arg.size())
+  if (arg.empty())
     return false;
   out->first = strtoull(arg.c_str(), &end, 10);
   if (end == arg.data())
diff --git a/src/trace_processor/importers/fuchsia/fuchsia_trace_tokenizer.cc b/src/trace_processor/importers/fuchsia/fuchsia_trace_tokenizer.cc
index 9cecd48..a78e896 100644
--- a/src/trace_processor/importers/fuchsia/fuchsia_trace_tokenizer.cc
+++ b/src/trace_processor/importers/fuchsia/fuchsia_trace_tokenizer.cc
@@ -99,7 +99,7 @@
                            data.get() + size);
     return util::OkStatus();
   }
-  if (leftover_bytes_.size() > 0) {
+  if (!leftover_bytes_.empty()) {
     // There is a record starting from leftover bytes.
     if (leftover_bytes_.size() < 8) {
       // Header was previously incomplete, but we have enough now.
diff --git a/src/trace_processor/importers/proto/stack_profile_tracker.cc b/src/trace_processor/importers/proto/stack_profile_tracker.cc
index 7d8ee5f..52e4dbd 100644
--- a/src/trace_processor/importers/proto/stack_profile_tracker.cc
+++ b/src/trace_processor/importers/proto/stack_profile_tracker.cc
@@ -70,7 +70,7 @@
   NullTermStringView raw_build_id_str =
       context_->storage->GetString(raw_build_id);
   StringId build_id = GetEmptyStringId();
-  if (raw_build_id_str.size() > 0) {
+  if (!raw_build_id_str.empty()) {
     // If the build_id is 33 characters long, we assume it's a Breakpad debug
     // identifier which is already in Hex and doesn't need conversion.
     // TODO(b/148109467): Remove workaround once all active Chrome versions
diff --git a/src/trace_processor/sqlite/span_join_operator_table.cc b/src/trace_processor/sqlite/span_join_operator_table.cc
index 1d84f37..1d4dc67 100644
--- a/src/trace_processor/sqlite/span_join_operator_table.cc
+++ b/src/trace_processor/sqlite/span_join_operator_table.cc
@@ -275,7 +275,7 @@
   for (size_t i = 0; i < qc.constraints().size(); i++) {
     const auto& cs = qc.constraints()[i];
     auto col_name = GetNameForGlobalColumnIndex(defn, cs.column);
-    if (col_name == "")
+    if (col_name.empty())
       continue;
 
     // Le constraints can be passed straight to the child tables as they won't
diff --git a/src/trace_processor/trace_processor_shell.cc b/src/trace_processor/trace_processor_shell.cc
index e02225d..c2755a9 100644
--- a/src/trace_processor/trace_processor_shell.cc
+++ b/src/trace_processor/trace_processor_shell.cc
@@ -117,14 +117,14 @@
 
 std::string GetPerfettoPath() {
   std::string config = GetConfigPath();
-  if (config == "")
+  if (config.empty())
     return "";
   return config + "/perfetto";
 }
 
 std::string GetHistoryPath() {
   std::string perfetto = GetPerfettoPath();
-  if (perfetto == "")
+  if (perfetto.empty())
     return "";
   return perfetto + "/.trace_processor_shell_history";
 }
@@ -133,7 +133,7 @@
   linenoiseSetMultiLine(true);
   linenoiseHistorySetMaxLen(1000);
 
-  bool success = GetHistoryPath() != "";
+  bool success = !GetHistoryPath().empty();
   success = success && EnsureDir(GetConfigPath());
   success = success && EnsureDir(GetPerfettoPath());
   success = success && EnsureFile(GetHistoryPath());
diff --git a/src/trace_processor/util/proto_to_json.cc b/src/trace_processor/util/proto_to_json.cc
index 1ab52fa..ff430c7 100644
--- a/src/trace_processor/util/proto_to_json.cc
+++ b/src/trace_processor/util/proto_to_json.cc
@@ -193,12 +193,12 @@
       }
       std::string nested_fields =
           NestedMessageFieldOptionsToJson(message, field_desc, indent + 2);
-      if (nested_fields != "") {
+      if (!nested_fields.empty()) {
         field_entries.push_back(std::move(nested_fields));
       }
       // We don't output annotations for a field if that field and all its
       // descendants have no field options.
-      if (field_entries.size() > 0) {
+      if (!field_entries.empty()) {
         if (field_desc->is_repeated()) {
           field_entries.push_back(std::string(indent, ' ') +
                                   R"("__repeated": true)");
@@ -273,13 +273,13 @@
   ret = "{" + MessageFieldsToJson(message, indent + 2);
   std::string annotation_fields =
       options_converter.MessageFieldOptionsToJson(message, indent + 4);
-  if (annotation_fields != "") {
+  if (annotation_fields.empty()) {
+    ret += "\n";
+  } else {
     ret += ",\n";
     ret += std::string(indent + 2, ' ') + "\"__annotations\": {\n";
     ret += annotation_fields + "\n";
     ret += std::string(indent + 2, ' ') + "}\n";
-  } else {
-    ret += "\n";
   }
   ret += std::string(indent, ' ') + "}\n";
   return ret;
diff --git a/src/tracing/internal/tracing_muxer_impl.cc b/src/tracing/internal/tracing_muxer_impl.cc
index 4130954..fe1a9de 100644
--- a/src/tracing/internal/tracing_muxer_impl.cc
+++ b/src/tracing/internal/tracing_muxer_impl.cc
@@ -366,7 +366,7 @@
   auto callback = read_trace_callback_;
   muxer_->task_runner_->PostTask([callback, buf, has_more] {
     TracingSession::ReadTraceCallbackArgs callback_arg{};
-    callback_arg.data = buf->size() ? &(*buf)[0] : nullptr;
+    callback_arg.data = buf->empty() ? nullptr : &(*buf)[0];
     callback_arg.size = buf->size();
     callback_arg.has_more = has_more;
     callback(callback_arg);