`status_internal`: add note about potential status message optimization In short, if most statuses are constructed with empty messages, or messages that are too long to fit into `std::string`'s local storage, we might save memory by getting rid of the local storage and always putting messages on the heap. PiperOrigin-RevId: 949730457 Change-Id: I7f47f036a16677c926078c7d48dabf8166af0f55
diff --git a/absl/status/internal/status_internal.h b/absl/status/internal/status_internal.h index 59ce36a..767f88f 100644 --- a/absl/status/internal/status_internal.h +++ b/absl/status/internal/status_internal.h
@@ -150,7 +150,13 @@ // As an internal implementation detail, we guarantee that if status.message() // is non-empty, then the resulting string_view is null terminated. // This is required to implement 'StatusMessageAsCStr(...)' + // + // NOTE: if most statuses are constructed with messages that are either empty + // or so long they don't fit in the std::string's local storage (small string + // optimization), replacing std::string with an entirely heap-allocated + // string might save memory at scale. std::string message_; + absl::InlinedVector<absl::SourceLocation, 1> source_locations_; std::unique_ptr<status_internal::Payloads> payloads_; };