From 1ee0ea84893e7d1edfc4fdaf192a0551a46e20b4 Mon Sep 17 00:00:00 2001 From: Michael Diamond Date: Sun, 6 Nov 2022 06:50:28 -0800 Subject: [PATCH] Fix a few lint findings in flags' usage.cc PiperOrigin-RevId: 486480813 Change-Id: I05292dd0550dfb4130bbe47eafa96ff5b58c040b --- absl/flags/internal/usage.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/absl/flags/internal/usage.cc b/absl/flags/internal/usage.cc index a3b13ed3..5efc7b07 100644 --- a/absl/flags/internal/usage.cc +++ b/absl/flags/internal/usage.cc @@ -17,7 +17,9 @@ #include +#include #include +#include #include #include #include @@ -33,6 +35,7 @@ #include "absl/flags/internal/program_name.h" #include "absl/flags/internal/registry.h" #include "absl/flags/usage_config.h" +#include "absl/strings/match.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_split.h" #include "absl/strings/string_view.h" @@ -343,7 +346,7 @@ void FlagHelp(std::ostream& out, const CommandLineFlag& flag, void FlagsHelp(std::ostream& out, absl::string_view filter, HelpFormat format, absl::string_view program_usage_message) { flags_internal::FlagKindFilter filter_cb = [&](absl::string_view filename) { - return filter.empty() || filename.find(filter) != absl::string_view::npos; + return filter.empty() || absl::StrContains(filename, filter); }; flags_internal::FlagsHelpImpl(out, filter_cb, format, program_usage_message); } @@ -465,7 +468,7 @@ void SetFlagsHelpFormat(HelpFormat format) { // function. bool DeduceUsageFlags(absl::string_view name, absl::string_view value) { if (absl::ConsumePrefix(&name, "help")) { - if (name == "") { + if (name.empty()) { if (value.empty()) { SetFlagsHelpMode(HelpMode::kImportant); } else {