Fix unnecessary switching of map representation for DiscardUnknownFields

pull/14879/head
Gerben 1 year ago
parent c5b3eb8059
commit fb0749ab8d
  1. 10
      src/google/protobuf/reflection_ops.cc

@ -327,14 +327,14 @@ void ReflectionOps::DiscardUnknownFields(Message* message) {
continue;
}
// Discard the unknown fields in maps that contain message values.
if (field->is_map() && IsMapValueMessageTyped(field)) {
const MapFieldBase* map_field =
reflection->MutableMapData(message, field);
if (map_field->IsMapValid()) {
const MapFieldBase* map_field = field->is_map() ?
reflection->MutableMapData(message, field) : nullptr;
if (map_field != nullptr && map_field->IsMapValid()) {
if (IsMapValueMessageTyped(field)) {
MapIterator iter(message, field);
MapIterator end(message, field);
for (map_field->MapBegin(&iter), map_field->MapEnd(&end); iter != end;
++iter) {
++iter) {
iter.MutableValueRef()->MutableMessageValue()->DiscardUnknownFields();
}
}

Loading…
Cancel
Save