From 6ce48c2d02204e7ecd30df1f648aa3302f1b5a48 Mon Sep 17 00:00:00 2001 From: Hong Shin Date: Wed, 20 Nov 2024 13:24:08 -0800 Subject: [PATCH] Automated rollback of commit 6b9d5c425e46eecd6b04b95bd5d3eb9056138e70. PiperOrigin-RevId: 698499250 --- hpb/hpb.h | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/hpb/hpb.h b/hpb/hpb.h index 5591f674ac..3becc509c3 100644 --- a/hpb/hpb.h +++ b/hpb/hpb.h @@ -95,11 +95,6 @@ ABSL_MUST_USE_RESULT bool Parse(Ptr message, absl::string_view bytes) { arena) == kUpb_DecodeStatus_Ok; } -template -ABSL_MUST_USE_RESULT bool Parse(T* message, absl::string_view bytes) { - return Parse(Ptr(message), bytes); -} - template absl::StatusOr Parse(absl::string_view bytes, int options = 0) { T message; @@ -114,6 +109,19 @@ absl::StatusOr Parse(absl::string_view bytes, int options = 0) { return MessageDecodeError(status); } +template +ABSL_MUST_USE_RESULT bool Parse(T* message, absl::string_view bytes) { + static_assert(!std::is_const_v); + upb_Message_Clear(hpb::interop::upb::GetMessage(message), + ::hpb::interop::upb::GetMiniTable(message)); + auto* arena = hpb::interop::upb::GetArena(message); + return upb_Decode(bytes.data(), bytes.size(), + hpb::interop::upb::GetMessage(message), + ::hpb::interop::upb::GetMiniTable(message), + /* extreg= */ nullptr, /* options= */ 0, + arena) == kUpb_DecodeStatus_Ok; +} + template absl::StatusOr Parse(absl::string_view bytes, const ::hpb::ExtensionRegistry& extension_registry,