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/json.cc b/internal/json.cc index f557a5491..44e1f4f63 100644 --- a/internal/json.cc +++ b/internal/json.cc @@ -806,7 +806,6 @@ class MessageToJsonState { if (size == 0) { return absl::OkStatus(); } - ReserveValues(result, size); CEL_ASSIGN_OR_RETURN(const auto to_value, GetRepeatedFieldToValue(field)); for (int index = 0; index < size; ++index) { CEL_RETURN_IF_ERROR((this->*to_value)(reflection, message, field, index, @@ -995,9 +994,6 @@ class MessageToJsonState { virtual absl::Nonnull MutableStructValue( absl::Nonnull message) const = 0; - virtual void ReserveValues(absl::Nonnull message, - int capacity) const = 0; - virtual absl::Nonnull AddValues( absl::Nonnull message) const = 0; @@ -1076,13 +1072,6 @@ class GeneratedMessageToJsonState final : public MessageToJsonState { google::protobuf::DownCastMessage(message)); } - void ReserveValues(absl::Nonnull message, - int capacity) const override { - ListValueReflection::ReserveValues( - google::protobuf::DownCastMessage(message), - capacity); - } - absl::Nonnull AddValues( absl::Nonnull message) const override { return ListValueReflection::AddValues( @@ -1163,12 +1152,6 @@ class DynamicMessageToJsonState final : public MessageToJsonState { google::protobuf::DownCastMessage(message)); } - void ReserveValues(absl::Nonnull message, - int capacity) const override { - reflection_.ListValue().ReserveValues( - google::protobuf::DownCastMessage(message), capacity); - } - absl::Nonnull AddValues( absl::Nonnull message) const override { return reflection_.ListValue().AddValues( @@ -2172,9 +2155,6 @@ class JsonMutator { virtual absl::Nonnull MutableListValue( absl::Nonnull message) const = 0; - virtual void ReserveValues(absl::Nonnull message, - int capacity) const = 0; - virtual absl::Nonnull AddValues( absl::Nonnull message) const = 0; @@ -2223,13 +2203,6 @@ class GeneratedJsonMutator final : public JsonMutator { google::protobuf::DownCastMessage(message)); } - void ReserveValues(absl::Nonnull message, - int capacity) const override { - ListValueReflection::ReserveValues( - google::protobuf::DownCastMessage(message), - capacity); - } - absl::Nonnull AddValues( absl::Nonnull message) const override { return ListValueReflection::AddValues( @@ -2312,12 +2285,6 @@ class DynamicJsonMutator final : public JsonMutator { google::protobuf::DownCastMessage(message)); } - void ReserveValues(absl::Nonnull message, - int capacity) const override { - list_value_reflection_.ReserveValues( - google::protobuf::DownCastMessage(message), capacity); - } - absl::Nonnull AddValues( absl::Nonnull message) const override { return list_value_reflection_.AddValues( @@ -2379,7 +2346,6 @@ class NativeJsonToProtoJsonState { absl::Status ToProtoJsonList(const JsonArray& json, absl::Nonnull proto) { - mutator_->ReserveValues(proto, static_cast(json.size())); for (const auto& element : json) { CEL_RETURN_IF_ERROR(ToProtoJson(element, mutator_->AddValues(proto))); } diff --git a/internal/well_known_types.cc b/internal/well_known_types.cc index 2e9cae6c6..085269ecd 100644 --- a/internal/well_known_types.cc +++ b/internal/well_known_types.cc @@ -1534,15 +1534,6 @@ absl::Nonnull ListValueReflection::AddValues( return message->GetReflection()->AddMessage(message, values_field_); } -void ListValueReflection::ReserveValues(absl::Nonnull message, - int capacity) const { - ABSL_DCHECK(IsInitialized()); - ABSL_DCHECK_EQ(message->GetDescriptor(), descriptor_); - if (capacity > 0) { - MutableValues(message).Reserve(capacity); - } -} - absl::StatusOr GetListValueReflection( absl::Nonnull descriptor) { ListValueReflection reflection; diff --git a/internal/well_known_types.h b/internal/well_known_types.h index 2cef32a96..4c3e70d20 100644 --- a/internal/well_known_types.h +++ b/internal/well_known_types.h @@ -1066,13 +1066,6 @@ class ListValueReflection final { return message->add_values(); } - static void ReserveValues(absl::Nonnull message, - int capacity) { - if (capacity > 0) { - message->mutable_values()->Reserve(capacity); - } - } - absl::Status Initialize(absl::Nonnull pool); absl::Status Initialize(absl::Nonnull descriptor); @@ -1110,9 +1103,6 @@ class ListValueReflection final { absl::Nonnull AddValues( absl::Nonnull message) const; - void ReserveValues(absl::Nonnull message, - int capacity) const; - private: absl::Nullable descriptor_ = nullptr; absl::Nullable values_field_ = nullptr;