Optimization: do not generate oneofs for proto3 optional fields.

Proto3 optional fields should use a hasbit for their presence.  But we had been giving them oneof layouts, which makes them unnecessarily large.  This CL will shrink messages with proto3 optional fields, by using hasbits instead of oneof cases for them.

PiperOrigin-RevId: 485998527
pull/13171/head
Joshua Haberman 2 years ago committed by Copybara-Service
parent 93fee65c55
commit 115b878a5c
  1. 2
      upb/reflection/message_def.c

@ -496,7 +496,7 @@ static bool _upb_MessageDef_EncodeMessage(upb_DescState* s,
s->ptr = upb_MtDataEncoder_PutField(&s->e, s->ptr, type, number, modifiers);
}
for (int i = 0; i < m->oneof_count; i++) {
for (int i = 0; i < m->real_oneof_count; i++) {
if (!_upb_DescState_Grow(s, a)) return false;
s->ptr = upb_MtDataEncoder_StartOneof(&s->e, s->ptr);

Loading…
Cancel
Save