@@ -32,7 +32,6 @@ using type_info = ::type_info;
32
32
#include " absl/base/optimization.h"
33
33
#include " absl/base/prefetch.h"
34
34
#include " absl/log/absl_check.h"
35
- #include " absl/utility/internal/if_constexpr.h"
36
35
#include " google/protobuf/arena_align.h"
37
36
#include " google/protobuf/arena_allocation_policy.h"
38
37
#include " google/protobuf/port.h"
@@ -195,41 +194,31 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final {
195
194
// otherwise, returns a heap-allocated object.
196
195
template <typename T, typename ... Args>
197
196
PROTOBUF_NDEBUG_INLINE static T* Create (Arena* arena, Args&&... args) {
198
- return absl::utility_internal::IfConstexprElse<
199
- is_arena_constructable<T>::value>(
200
- // Arena-constructable
201
- [arena](auto &&... args) {
202
- using Type = std::remove_const_t <T>;
203
- #ifdef __cpp_if_constexpr
204
- // DefaultConstruct/CopyConstruct are optimized for messages, which
205
- // are both arena constructible and destructor skippable and they
206
- // assume much. Don't use these functions unless the invariants
207
- // hold.
208
- if constexpr (is_destructor_skippable<T>::value) {
209
- constexpr auto construct_type = GetConstructType<T, Args&&...>();
210
- // We delegate to DefaultConstruct/CopyConstruct where appropriate
211
- // because protobuf generated classes have external templates for
212
- // these functions for code size reasons. When `if constexpr` is not
213
- // available always use the fallback.
214
- if constexpr (construct_type == ConstructType::kDefault ) {
215
- return static_cast <Type*>(DefaultConstruct<Type>(arena));
216
- } else if constexpr (construct_type == ConstructType::kCopy ) {
217
- return static_cast <Type*>(CopyConstruct<Type>(arena, &args...));
218
- }
219
- }
220
- #endif
221
- return CreateArenaCompatible<Type>(arena,
222
- std::forward<Args>(args)...);
223
- },
224
- // Non arena-constructable
225
- [arena](auto &&... args) {
226
- if (ABSL_PREDICT_FALSE (arena == nullptr )) {
227
- return new T (std::forward<Args>(args)...);
228
- }
229
- return new (arena->AllocateInternal <T>())
230
- T (std::forward<Args>(args)...);
231
- },
232
- std::forward<Args>(args)...);
197
+ if constexpr (is_arena_constructable<T>::value) {
198
+ using Type = std::remove_const_t <T>;
199
+ // DefaultConstruct/CopyConstruct are optimized for messages, which
200
+ // are both arena constructible and destructor skippable and they
201
+ // assume much. Don't use these functions unless the invariants
202
+ // hold.
203
+ if constexpr (is_destructor_skippable<T>::value) {
204
+ constexpr auto construct_type = GetConstructType<T, Args&&...>();
205
+ // We delegate to DefaultConstruct/CopyConstruct where appropriate
206
+ // because protobuf generated classes have external templates for
207
+ // these functions for code size reasons. When `if constexpr` is not
208
+ // available always use the fallback.
209
+ if constexpr (construct_type == ConstructType::kDefault ) {
210
+ return static_cast <Type*>(DefaultConstruct<Type>(arena));
211
+ } else if constexpr (construct_type == ConstructType::kCopy ) {
212
+ return static_cast <Type*>(CopyConstruct<Type>(arena, &args...));
213
+ }
214
+ }
215
+ return CreateArenaCompatible<Type>(arena, std::forward<Args>(args)...);
216
+ } else {
217
+ if (ABSL_PREDICT_FALSE (arena == nullptr )) {
218
+ return new T (std::forward<Args>(args)...);
219
+ }
220
+ return new (arena->AllocateInternal <T>()) T (std::forward<Args>(args)...);
221
+ }
233
222
}
234
223
235
224
// API to delete any objects not on an arena. This can be used to safely
0 commit comments