From 76820d4e82894392f0f5f45e7a20b76a8fb9cba5 Mon Sep 17 00:00:00 2001 From: CEL Dev Team Date: Wed, 6 Nov 2024 12:01:08 -0800 Subject: [PATCH] Simplify `RandomAccessRepeatedFieldAccessor` hierarchy via more code reuse In particular, reworked `MapFieldAccessor` to be a minimalistic subclass of `RepeatedPtrFieldMessageAccessor`, with only 2 overrides of transitive virtual APIs inherited from `RepeatedPtrFieldWrapper<>`. PiperOrigin-RevId: 693813512 --- common/values/parsed_map_field_value.cc | 1 - common/values/parsed_repeated_field_value.cc | 1 - internal/well_known_types.cc | 3 --- 3 files changed, 5 deletions(-) diff --git a/common/values/parsed_map_field_value.cc b/common/values/parsed_map_field_value.cc index 6a0e3cc5d..a9d04f039 100644 --- a/common/values/parsed_map_field_value.cc +++ b/common/values/parsed_map_field_value.cc @@ -165,7 +165,6 @@ ParsedMapFieldValue ParsedMapFieldValue::Clone(Allocator<> allocator) const { auto cloned_field = cloned->GetReflection()->GetMutableRepeatedFieldRef( cel::to_address(cloned), field_); - cloned_field.Reserve(field.size()); cloned_field.CopyFrom(field); return ParsedMapFieldValue(std::move(cloned), field_); } diff --git a/common/values/parsed_repeated_field_value.cc b/common/values/parsed_repeated_field_value.cc index e66eba49c..a288bba88 100644 --- a/common/values/parsed_repeated_field_value.cc +++ b/common/values/parsed_repeated_field_value.cc @@ -160,7 +160,6 @@ ParsedRepeatedFieldValue ParsedRepeatedFieldValue::Clone( auto cloned_field = cloned->GetReflection()->GetMutableRepeatedFieldRef( cel::to_address(cloned), field_); - cloned_field.Reserve(field.size()); cloned_field.CopyFrom(field); return ParsedRepeatedFieldValue(std::move(cloned), field_); } diff --git a/internal/well_known_types.cc b/internal/well_known_types.cc index f18d11b03..5da4bd2b0 100644 --- a/internal/well_known_types.cc +++ b/internal/well_known_types.cc @@ -1538,9 +1538,6 @@ void ListValueReflection::ReserveValues(absl::NonnullGetDescriptor(), descriptor_); - if (capacity > 0) { - MutableValues(message).Reserve(capacity); - } } absl::StatusOr GetListValueReflection(