Make proto allocation with Arenas faster PiperOrigin-RevId: 493503091
diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h index abce219..ee41320 100644 --- a/src/google/protobuf/arena.h +++ b/src/google/protobuf/arena.h
@@ -552,7 +552,7 @@ static_assert( InternalHelper<T>::is_arena_constructable::value, "CreateMessage can only construct types that are ArenaConstructable"); - if (arena == nullptr) { + if (PROTOBUF_PREDICT_FALSE(arena == nullptr)) { return new T(nullptr, static_cast<Args&&>(args)...); } else { return arena->DoCreateMessage<T>(static_cast<Args&&>(args)...); @@ -642,7 +642,7 @@ CreateInArenaStorageInternal(ptr, arena, typename is_arena_constructable<T>::type(), std::forward<Args>(args)...); - if (arena != nullptr) { + if (PROTOBUF_PREDICT_TRUE(arena != nullptr)) { RegisterDestructorInternal( ptr, arena, typename InternalHelper<T>::is_destructor_skippable::type());