diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h index 545fd5126..55b1ec83b 100644 --- a/src/google/protobuf/arena.h +++ b/src/google/protobuf/arena.h @@ -32,7 +32,6 @@ using type_info = ::type_info; #include "absl/base/optimization.h" #include "absl/base/prefetch.h" #include "absl/log/absl_check.h" -#include "absl/utility/internal/if_constexpr.h" #include "google/protobuf/arena_align.h" #include "google/protobuf/arena_allocation_policy.h" #include "google/protobuf/port.h" @@ -214,41 +213,31 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { // otherwise, returns a heap-allocated object. template PROTOBUF_NDEBUG_INLINE static T* Create(Arena* arena, Args&&... args) { - return absl::utility_internal::IfConstexprElse< - is_arena_constructable::value>( - // Arena-constructable - [arena](auto&&... args) { - using Type = std::remove_const_t; -#ifdef __cpp_if_constexpr - // DefaultConstruct/CopyConstruct are optimized for messages, which - // are both arena constructible and destructor skippable and they - // assume much. Don't use these functions unless the invariants - // hold. - if constexpr (is_destructor_skippable::value) { - constexpr auto construct_type = GetConstructType(); - // We delegate to DefaultConstruct/CopyConstruct where appropriate - // because protobuf generated classes have external templates for - // these functions for code size reasons. When `if constexpr` is not - // available always use the fallback. - if constexpr (construct_type == ConstructType::kDefault) { - return static_cast(DefaultConstruct(arena)); - } else if constexpr (construct_type == ConstructType::kCopy) { - return static_cast(CopyConstruct(arena, &args...)); - } - } -#endif - return CreateArenaCompatible(arena, - std::forward(args)...); - }, - // Non arena-constructable - [arena](auto&&... args) { - if (PROTOBUF_PREDICT_FALSE(arena == nullptr)) { - return new T(std::forward(args)...); - } - return new (arena->AllocateInternal()) - T(std::forward(args)...); - }, - std::forward(args)...); + if constexpr (is_arena_constructable::value) { + using Type = std::remove_const_t; + // DefaultConstruct/CopyConstruct are optimized for messages, which + // are both arena constructible and destructor skippable and they + // assume much. Don't use these functions unless the invariants + // hold. + if constexpr (is_destructor_skippable::value) { + constexpr auto construct_type = GetConstructType(); + // We delegate to DefaultConstruct/CopyConstruct where appropriate + // because protobuf generated classes have external templates for + // these functions for code size reasons. When `if constexpr` is not + // available always use the fallback. + if constexpr (construct_type == ConstructType::kDefault) { + return static_cast(DefaultConstruct(arena)); + } else if constexpr (construct_type == ConstructType::kCopy) { + return static_cast(CopyConstruct(arena, &args...)); + } + } + return CreateArenaCompatible(arena, std::forward(args)...); + } else { + if (ABSL_PREDICT_FALSE(arena == nullptr)) { + return new T(std::forward(args)...); + } + return new (arena->AllocateInternal()) T(std::forward(args)...); + } } // API to delete any objects not on an arena. This can be used to safely diff --git a/cmake/abseil-cpp.cmake b/cmake/abseil-cpp.cmake index 1b64affa5..c45fb222a 100644 --- a/cmake/abseil-cpp.cmake +++ b/cmake/abseil-cpp.cmake @@ -72,7 +72,6 @@ else() absl::flat_hash_set absl::function_ref absl::hash - absl::if_constexpr absl::layout absl::log_initialize absl::log_globals