[cleanup] Move strings if possible in grpc::Status (#40443)

Closes #40443

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/40443 from apolukhin:status-optimize d53b7ad8901d0b0d5ef53c356d79e45433ebbcf6
PiperOrigin-RevId: 859387690
This commit is contained in:
Antony Polukhin
2026-01-21 20:40:30 -08:00
committed by Copybara-Service
parent c11767fda5
commit d7f3d36f68

View File

@@ -95,17 +95,16 @@ class GRPC_MUST_USE_RESULT_WHEN_USE_STRICT_WARNING GRPCXX_DLL Status {
/// instead of a value (which results in a copy instead of a move) to allow
/// for easy transition to absl::Status in the future which accepts an
/// absl::string_view as a parameter.
Status(StatusCode code, const std::string& error_message)
: code_(code), error_message_(error_message) {}
Status(StatusCode code, std::string error_message)
: code_(code), error_message_(std::move(error_message)) {}
/// Construct an instance with \a code, \a error_message and
/// \a error_details. It is an error to construct an OK status with non-empty
/// \a error_message and/or \a error_details.
Status(StatusCode code, const std::string& error_message,
const std::string& error_details)
Status(StatusCode code, std::string error_message, std::string error_details)
: code_(code),
error_message_(error_message),
binary_error_details_(error_details) {}
error_message_(std::move(error_message)),
binary_error_details_(std::move(error_details)) {}
// Pre-defined special status objects.
/// An OK pre-defined instance.