@@ -119,11 +119,11 @@ class MessageCreator {
119119 func_(func) {}
120120
121121 // Template for testing.
122- template <bool test_call = false , typename MessageLite>
122+ template <typename MessageLite>
123123 MessageLite* New (const MessageLite* prototype_for_func,
124124 const MessageLite* prototype_for_copy, Arena* arena) const ;
125125
126- template <bool test_call = false , typename MessageLite>
126+ template <typename MessageLite>
127127 MessageLite* PlacementNew (const MessageLite* prototype_for_func,
128128 const MessageLite* prototype_for_copy, void * mem,
129129 Arena* arena) const ;
@@ -1187,19 +1187,15 @@ inline void AssertDownCast(const MessageLite& from, const MessageLite& to) {
11871187 << " Cannot downcast " << from.GetTypeName () << " to " << to.GetTypeName ();
11881188}
11891189
1190- template <bool test_call, typename MessageLite>
1190+ template <typename MessageLite>
11911191PROTOBUF_ALWAYS_INLINE inline MessageLite* MessageCreator::PlacementNew (
11921192 const MessageLite* prototype_for_func,
11931193 const MessageLite* prototype_for_copy, void * mem, Arena* arena) const {
11941194 ABSL_DCHECK_EQ (reinterpret_cast <uintptr_t >(mem) % alignment_, 0u );
11951195 const Tag as_tag = tag ();
1196- // When the feature is not enabled we skip the `as_tag` check since it is
1197- // unnecessary. Except for testing, where we want to test the copy logic even
1198- // when we can't use it for real messages.
1199- constexpr bool kMustBeFunc = !test_call && !internal::EnableCustomNew ();
12001196 static_assert (kFunc < 0 && !(kZeroInit < 0 ) && !(kMemcpy < 0 ),
12011197 " Only kFunc must be the only negative value" );
1202- if (ABSL_PREDICT_FALSE (kMustBeFunc || as_tag < 0 )) {
1198+ if (ABSL_PREDICT_FALSE (static_cast < int8_t >( as_tag) < 0 )) {
12031199 PROTOBUF_DEBUG_COUNTER (" MessageCreator.Func" ).Inc ();
12041200 return static_cast <MessageLite*>(func_ (prototype_for_func, mem, arena));
12051201 }
@@ -1293,15 +1289,15 @@ PROTOBUF_ALWAYS_INLINE inline MessageLite* MessageCreator::PlacementNew(
12931289 return Launder (reinterpret_cast <MessageLite*>(mem));
12941290}
12951291
1296- template <bool test_call, typename MessageLite>
1292+ template <typename MessageLite>
12971293PROTOBUF_ALWAYS_INLINE inline MessageLite* MessageCreator::New (
12981294 const MessageLite* prototype_for_func,
12991295 const MessageLite* prototype_for_copy, Arena* arena) const {
1300- return PlacementNew<test_call> (prototype_for_func, prototype_for_copy,
1301- arena != nullptr
1302- ? arena->AllocateAligned (allocation_size_)
1303- : ::operator new (allocation_size_),
1304- arena);
1296+ return PlacementNew (prototype_for_func, prototype_for_copy,
1297+ arena != nullptr
1298+ ? arena->AllocateAligned (allocation_size_)
1299+ : ::operator new (allocation_size_),
1300+ arena);
13051301}
13061302
13071303} // namespace internal
0 commit comments