From c7a723bbb534753fe3944d8de5d2a15bda42b12d Mon Sep 17 00:00:00 2001 From: Chris Kennelly Date: Tue, 6 Aug 2024 13:56:50 -0700 Subject: [PATCH] Remove Arena::CreateMessage. It has equivalent performance to Arena::Create. PiperOrigin-RevId: 660086722 --- src/google/protobuf/arena.h | 5 +++-- src/google/protobuf/port_def.inc | 4 ++++ src/google/protobuf/port_undef.inc | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h index a803751832..a853034140 100644 --- a/src/google/protobuf/arena.h +++ b/src/google/protobuf/arena.h @@ -176,8 +176,8 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { inline ~Arena() = default; - // Deprecated. Use Create instead. TODO: depreate OSS version - // once internal migration to Arena::Create is done. +#ifndef PROTOBUF_FUTURE_REMOVE_CREATEMESSAGE + // Deprecated. Use Create instead. template ABSL_DEPRECATED("Use Create") static T* CreateMessage(Arena* arena, Args&&... args) { @@ -187,6 +187,7 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { "CreateMessage can only construct types that are ArenaConstructable"); return Create(arena, std::forward(args)...); } +#endif // !PROTOBUF_FUTURE_REMOVE_CREATEMESSAGE // Allocates an object type T if the arena passed in is not nullptr; // otherwise, returns a heap-allocated object. diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc index 52fa1b315b..3377937f3b 100644 --- a/src/google/protobuf/port_def.inc +++ b/src/google/protobuf/port_def.inc @@ -143,6 +143,10 @@ static_assert(PROTOBUF_ABSL_MIN(20230125, 3), // Owner: shaod@, gberg@ #define PROTOBUF_FUTURE_DESCRIPTOR_EXTENSION_DECL 1 +// Removes Arena::CreateMessage, as Arena::Create is equivalent +// Owner: ckennelly@, mkruskal@ +#define PROTOBUF_FUTURE_REMOVE_CREATEMESSAGE 1 + #endif #ifdef PROTOBUF_FUTURE_STRING_VIEW_RETURN_TYPE diff --git a/src/google/protobuf/port_undef.inc b/src/google/protobuf/port_undef.inc index 0855b44c7f..c87f37e94c 100644 --- a/src/google/protobuf/port_undef.inc +++ b/src/google/protobuf/port_undef.inc @@ -84,6 +84,7 @@ #undef PROTOBUF_FUTURE_BREAKING_CHANGES #undef PROTOBUF_FUTURE_DESCRIPTOR_EXTENSION_DECL #undef PROTOBUF_FUTURE_STRING_VIEW_RETURN_TYPE +#undef PROTOBUF_FUTURE_REMOVE_CREATEMESSAGE #endif // Restore macros that may have been #undef'd in port_def.inc.