Skip to content

Add generated message fast-paths for JSON well-known types. - #2358

Merged
copybara-service[bot] merged 1 commit into
masterfrom
test_996898131
Oct 12, 2026
Merged

copybara-service[bot] merged 1 commit into
masterfrom
test_996898131

Conversation

@copybara-service

Copy link
Copy Markdown

Add generated message fast-paths for JSON well-known types.

ParsedJsonMapValue, ParsedJsonListValue, and ParsedJsonValue previously always accessed google.protobuf.Struct, google.protobuf.ListValue, and google.protobuf.Value via descriptor/reflection lookups (FindFieldByNumber, GetReflection(), MapSize, LookupMapValue, GetRepeatedMessage, ListFields), and ParsedJsonValue copied string_value onto the evaluation arena even when the google.protobuf.Value message was already arena-allocated.

Try proto2::DynamicCastMessage to the generated google::protobuf::Struct, google::protobuf::ListValue, and google::protobuf::Value types first (falling back to reflection for dynamic messages), and use StringValue::Wrap when value->GetArena() != nullptr so arena-owned string_value strings are borrowed zero-copy.

@copybara-service
copybara-service Bot force-pushed the test_996898131 branch 2 times, most recently from 8b313e3 to 23ef6d6 Compare October 12, 2026 18:47
`ParsedJsonMapValue`, `ParsedJsonListValue`, and `ParsedJsonValue` previously always accessed `google.protobuf.Struct`, `google.protobuf.ListValue`, and `google.protobuf.Value` via descriptor/reflection lookups (`FindFieldByNumber`, `GetReflection()`, `MapSize`, `LookupMapValue`, `GetRepeatedMessage`, `ListFields`), and `ParsedJsonValue` copied `string_value` onto the evaluation arena even when the `google.protobuf.Value` message was already arena-allocated.

Try `proto2::DynamicCastMessage` to the generated `google::protobuf::Struct`, `google::protobuf::ListValue`, and `google::protobuf::Value` types first (falling back to reflection for dynamic messages), and use `StringValue::Wrap` when `value->GetArena() != nullptr` so arena-owned `string_value` strings are borrowed zero-copy.

PiperOrigin-RevId: 998080226
@copybara-service
copybara-service Bot merged commit b5e6a2f into master Oct 12, 2026
2 checks passed
@copybara-service
copybara-service Bot deleted the test_996898131 branch October 12, 2026 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants