diff options
author | Mateus Azis <azis@google.com> | 2023-06-15 23:50:33 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-06-15 23:50:33 +0000 |
commit | effe65703f8ad7568e3718605094effee778b904 (patch) | |
tree | 249e6fa6e509b19e4b23e44e4c0a3036b1d72a58 | |
parent | b3b36edd4230932c67f044051dcd6ec286717567 (diff) | |
parent | 1813520e5b7b4e97d5fb45be702a5019c78bc6d1 (diff) | |
download | gtest_extras-effe65703f8ad7568e3718605094effee778b904.tar.gz |
Remove unnecessary string copies from "PrintError". am: 7614170cfc am: b5f7d7da55 am: a97bcb90fd am: 5e2046012d am: fd862f6a71 am: 1813520e5b
Original change: https://android-review.googlesource.com/c/platform/system/testing/gtest_extras/+/2626395
Change-Id: Iec741e9177cabe76a7d21c83142f7244ff4e90cb
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | Options.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Options.cpp b/Options.cpp index 36f618d..0762d0b 100644 --- a/Options.cpp +++ b/Options.cpp @@ -28,6 +28,7 @@ #include <charconv> #include <regex> #include <string> +#include <string_view> #include <unordered_map> #include <vector> @@ -78,16 +79,16 @@ const std::unordered_map<std::string, Options::ArgInfo> Options::kArgs = { {"gtest_format", {FLAG_NONE, &Options::SetBool}}, }; -static void PrintError(const std::string& arg, std::string msg, bool from_env) { +static void PrintError(const std::string& arg, std::string_view msg, bool from_env) { if (from_env) { std::string variable(arg); std::transform(variable.begin(), variable.end(), variable.begin(), [](char c) { return std::toupper(c); }); - printf("env[%s] %s\n", variable.c_str(), msg.c_str()); + printf("env[%s] %s\n", variable.c_str(), msg.data()); } else if (arg[0] == '-') { - printf("%s %s\n", arg.c_str(), msg.c_str()); + printf("%s %s\n", arg.c_str(), msg.data()); } else { - printf("--%s %s\n", arg.c_str(), msg.c_str()); + printf("--%s %s\n", arg.c_str(), msg.data()); } } |