@@ -742,8 +742,16 @@ template <typename T>
742
742
PROTOBUF_NOINLINE void * PROTOBUF_NONNULL
743
743
Arena::DefaultConstruct (Arena* PROTOBUF_NULLABLE arena) {
744
744
static_assert (is_destructor_skippable<T>::value, " " );
745
- void * mem = arena != nullptr ? arena->AllocateAligned (sizeof (T))
746
- : ::operator new (sizeof (T));
745
+ void * mem;
746
+ if (arena != nullptr ) {
747
+ mem = arena->AllocateAligned (sizeof (T));
748
+ } else {
749
+ #if ABSL_HAVE_BUILTIN(__builtin_operator_new)
750
+ mem = __builtin_operator_new (sizeof (T));
751
+ #else
752
+ mem = ::operator new (sizeof (T));
753
+ #endif
754
+ }
747
755
return new (mem) T (arena);
748
756
}
749
757
@@ -766,8 +774,16 @@ PROTOBUF_NOINLINE void* PROTOBUF_NONNULL Arena::CopyConstruct(
766
774
internal::Prefetch<kPrefetchOpts , T, T>(typed_from);
767
775
}
768
776
static_assert (is_destructor_skippable<T>::value, " " );
769
- void * mem = arena != nullptr ? arena->AllocateAligned (sizeof (T))
770
- : ::operator new (sizeof (T));
777
+ void * mem;
778
+ if (arena != nullptr ) {
779
+ mem = arena->AllocateAligned (sizeof (T));
780
+ } else {
781
+ #if ABSL_HAVE_BUILTIN(__builtin_operator_new)
782
+ mem = __builtin_operator_new (sizeof (T));
783
+ #else
784
+ mem = ::operator new (sizeof (T));
785
+ #endif
786
+ }
771
787
return new (mem) T (arena, *typed_from);
772
788
}
773
789
0 commit comments