Let ParseRepeatedStringOnce call AllocateFromStringBlock().

PiperOrigin-RevId: 542617650
pull/13127/head
Protobuf Team Bot 1 year ago committed by Copybara-Service
parent fd5167d40e
commit bcf3e36a48
  1. 4
      src/google/protobuf/generated_message_tctable_impl.h
  2. 8
      src/google/protobuf/generated_message_tctable_lite.cc

@ -808,8 +808,8 @@ class PROTOBUF_EXPORT TcParser final {
static inline const char* RepeatedString(PROTOBUF_TC_PARAM_DECL);
static inline const char* ParseRepeatedStringOnce(
const char* ptr, Arena* arena, SerialArena* serial_arena,
ParseContext* ctx, RepeatedPtrField<std::string>& field);
const char* ptr, SerialArena* serial_arena, ParseContext* ctx,
RepeatedPtrField<std::string>& field);
static void AddUnknownEnum(MessageLite* msg, const TcParseTableBase* table,
uint32_t tag, int32_t enum_value);

@ -1684,7 +1684,7 @@ PROTOBUF_ALWAYS_INLINE const char* TcParser::RepeatedString(
field.PrepareForParse())) {
do {
ptr += sizeof(TagType);
ptr = ParseRepeatedStringOnce(ptr, arena, serial_arena, ctx, field);
ptr = ParseRepeatedStringOnce(ptr, serial_arena, ctx, field);
if (PROTOBUF_PREDICT_FALSE(ptr == nullptr || !validate_last_string())) {
PROTOBUF_MUSTTAIL return Error(PROTOBUF_TC_PARAM_NO_DATA_PASS);
@ -2273,11 +2273,11 @@ PROTOBUF_NOINLINE const char* TcParser::MpString(PROTOBUF_TC_PARAM_DECL) {
}
PROTOBUF_ALWAYS_INLINE const char* TcParser::ParseRepeatedStringOnce(
const char* ptr, Arena* arena, SerialArena* serial_arena, ParseContext* ctx,
const char* ptr, SerialArena* serial_arena, ParseContext* ctx,
RepeatedPtrField<std::string>& field) {
int size = ReadSize(&ptr);
if (PROTOBUF_PREDICT_FALSE(!ptr)) return {};
auto* str = Arena::Create<std::string>(arena);
auto* str = new (serial_arena->AllocateFromStringBlock()) std::string();
field.AddAllocatedForParse(str);
ptr = ctx->ReadString(ptr, size, str);
if (PROTOBUF_PREDICT_FALSE(!ptr)) return {};
@ -2312,7 +2312,7 @@ PROTOBUF_NOINLINE const char* TcParser::MpRepeatedString(
field.PrepareForParse())) {
do {
ptr = ptr2;
ptr = ParseRepeatedStringOnce(ptr, arena, serial_arena, ctx, field);
ptr = ParseRepeatedStringOnce(ptr, serial_arena, ctx, field);
if (PROTOBUF_PREDICT_FALSE(ptr == nullptr ||
!MpVerifyUtf8(field[field.size() - 1],
table, entry, xform_val))) {

Loading…
Cancel
Save