This feature allows for tree shaking within a single .proto file, dropping
unused types while still allowing reflection to work for them via the generated
DescriptorPool.
PiperOrigin-RevId: 587066283
When unknown fields are discarded using reflection in reflection_ops.cc, unnecessary switching of the internal map representation is triggered.
A map<int,int> field cannot have unknown fields. However, in the current code the check used is
if (field->IsMap() && IsMapValueMessageTyped(field)) {
// Discard map field
} else {
// Discard repeated message field
}
This means that the code proceeds discarding unknown fields for each mapentry using the RepeatedPtrField of MapEntry representation of the map. Causing unnecessary work and unnecessary, potentially big, memory allocation. This PR fixes this.
See also issue https://github.com/protocolbuffers/protobuf/issues/13222
This is also a bug fix. When a map<int, MyProto> is in a dirty state, previously it would be skipped. After this change it will correctly use the repeated path to clean the MyProto sub-entries
Closes#14879
COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/14879 from gerben-stavenga:patch_discardunknown fb0749ab8d
PiperOrigin-RevId: 586820137
In Java, in order to include Extensions inside a proto message, the ExtensionRegistry for the extensions must be included during deserialization, otherwise they are treated as unknown fields.
This change adds support for providing an ExtensionRegistry for TextFormat.Printer which is then used during Any deserialization.
PiperOrigin-RevId: 586807633
It's up to the user how to set up the threads, but this will allow them to dispatch any recursive work during the descriptor builds to separate threads with their own stack limit.
PiperOrigin-RevId: 586774613
This is similar to what we did for built-in generators, and gives us the ability to create a new edition without subtley breaking generators that don't support it yet.
PiperOrigin-RevId: 586756816
- Remove _Internal accessors. They only have one caller and it's better to inline it.
- Remove redundant has bit setting. MergeFrom does it globally instead of per field.
- Reuse existing arena object. Avoids redundant calls to `GetArena()`.
- Use rhs object instead of weak instance for calling `New()`.
- Change repeated fields to use the generic MergeFrom instead of Arena::CopyConstruct.
PiperOrigin-RevId: 586680126
This caused an issue on some platforms where `protobuf/java/core/src/main/java/com/google/protobuf/java_features.proto` was getting turned into the invalid path `java/core/src/main/java/com/google/java_features.proto`.
Fixes#14862
PiperOrigin-RevId: 586527713
Users should migrate to corresponding feature accessors (e.g. FieldDescriptor.hasPresence, EnumDescriptor.isClosed) instead of deriving these based on syntax, which will break after under Editions (https://protobuf.dev/editions/overview/)
PiperOrigin-RevId: 586518687
This is functionally equivalent, but avoids a codegen change under editions where the inherited value of utf8_validation can change for non-string maps.
PiperOrigin-RevId: 586493296