File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change 3333#include < utility>
3434
3535#include " absl/base/attributes.h"
36+ #include " absl/base/config.h"
3637#include " absl/log/absl_check.h"
3738#include " absl/numeric/bits.h"
3839#include " absl/strings/cord.h"
@@ -1445,11 +1446,19 @@ template <typename MessageLite>
14451446PROTOBUF_ALWAYS_INLINE MessageLite* MessageCreator::New (
14461447 const MessageLite* prototype_for_func,
14471448 const MessageLite* prototype_for_copy, Arena* arena) const {
1448- return PlacementNew (prototype_for_func, prototype_for_copy,
1449- arena != nullptr
1450- ? arena->AllocateAligned (allocation_size_)
1451- : ::operator new (allocation_size_),
1452- arena);
1449+ void * mem;
1450+ if (arena != nullptr ) {
1451+ mem = arena->AllocateAligned (allocation_size_);
1452+ } else {
1453+ #if ABSL_HAVE_BUILTIN(__builtin_operator_new)
1454+ // Allows the compiler to merge or optimize away the allocation even if it
1455+ // would violate the observability guarantees of ::operator new.
1456+ mem = __builtin_operator_new (allocation_size_);
1457+ #else
1458+ mem = ::operator new (allocation_size_);
1459+ #endif
1460+ }
1461+ return PlacementNew (prototype_for_func, prototype_for_copy, mem, arena);
14531462}
14541463
14551464} // namespace internal
You can’t perform that action at this time.
0 commit comments