From 1575e7f79c1697b3cf308f251dd0bf52d77edfd4 Mon Sep 17 00:00:00 2001 From: MediaPipe Team Date: Sun, 26 Feb 2023 11:52:32 -0800 Subject: [PATCH] Internal change PiperOrigin-RevId: 512457466 --- mediapipe/framework/tool/status_util.cc | 9 +++++---- mediapipe/framework/tool/status_util.h | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/mediapipe/framework/tool/status_util.cc b/mediapipe/framework/tool/status_util.cc index 0e3a59246..401a1b63c 100644 --- a/mediapipe/framework/tool/status_util.cc +++ b/mediapipe/framework/tool/status_util.cc @@ -18,15 +18,16 @@ #include "absl/strings/str_cat.h" #include "absl/strings/str_join.h" +#include "absl/strings/string_view.h" namespace mediapipe { namespace tool { -absl::Status StatusInvalid(const std::string& message) { +absl::Status StatusInvalid(absl::string_view message) { return absl::Status(absl::StatusCode::kInvalidArgument, message); } -absl::Status StatusFail(const std::string& message) { +absl::Status StatusFail(absl::string_view message) { return absl::Status(absl::StatusCode::kUnknown, message); } @@ -35,12 +36,12 @@ absl::Status StatusStop() { "mediapipe::tool::StatusStop()"); } -absl::Status AddStatusPrefix(const std::string& prefix, +absl::Status AddStatusPrefix(absl::string_view prefix, const absl::Status& status) { return absl::Status(status.code(), absl::StrCat(prefix, status.message())); } -absl::Status CombinedStatus(const std::string& general_comment, +absl::Status CombinedStatus(absl::string_view general_comment, const std::vector& statuses) { // The final error code is absl::StatusCode::kUnknown if not all // the error codes are the same. Otherwise it is the same error code diff --git a/mediapipe/framework/tool/status_util.h b/mediapipe/framework/tool/status_util.h index 8b4bc02d2..0db03ec4d 100644 --- a/mediapipe/framework/tool/status_util.h +++ b/mediapipe/framework/tool/status_util.h @@ -19,6 +19,7 @@ #include #include "absl/base/macros.h" +#include "absl/strings/string_view.h" #include "mediapipe/framework/port/status.h" namespace mediapipe { @@ -34,16 +35,16 @@ absl::Status StatusStop(); // Return a status which signals an invalid initial condition (for // example an InputSidePacket does not include all necessary fields). ABSL_DEPRECATED("Use absl::InvalidArgumentError(error_message) instead.") -absl::Status StatusInvalid(const std::string& error_message); +absl::Status StatusInvalid(absl::string_view error_message); // Return a status which signals that something unexpectedly failed. ABSL_DEPRECATED("Use absl::UnknownError(error_message) instead.") -absl::Status StatusFail(const std::string& error_message); +absl::Status StatusFail(absl::string_view error_message); // Prefixes the given string to the error message in status. // This function should be considered internal to the framework. // TODO Replace usage of AddStatusPrefix with util::Annotate(). -absl::Status AddStatusPrefix(const std::string& prefix, +absl::Status AddStatusPrefix(absl::string_view prefix, const absl::Status& status); // Combine a vector of absl::Status into a single composite status. @@ -51,7 +52,7 @@ absl::Status AddStatusPrefix(const std::string& prefix, // will be returned. // This function should be considered internal to the framework. // TODO Move this function to somewhere with less visibility. -absl::Status CombinedStatus(const std::string& general_comment, +absl::Status CombinedStatus(absl::string_view general_comment, const std::vector& statuses); } // namespace tool