Skip to content

Commit

Permalink
Deprecate MutableRepeatedFieldRef::Reserve() (in reflection)
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 704882459
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Dec 11, 2024
1 parent 283a96f commit 7fc92a8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/google/protobuf/reflection.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <memory>
#include <type_traits>

#include "absl/base/attributes.h"
#include "google/protobuf/generated_enum_util.h"
#include "google/protobuf/descriptor.h"

Expand Down Expand Up @@ -96,6 +97,8 @@ class MutableRepeatedFieldRef<
}
void Add(const T& value) const { accessor_->template Add<T>(data_, value); }
void RemoveLast() const { accessor_->RemoveLast(data_); }
// TODO: Remove.
ABSL_DEPRECATED("Do not use. Will be removed in a future release.")
void Reserve(int size) const { accessor_->Reserve(data_, size); }
void SwapElements(int index1, int index2) const {
accessor_->SwapElements(data_, index1, index2);
Expand Down Expand Up @@ -215,6 +218,8 @@ class MutableRepeatedFieldRef<
}
void Add(const T& value) const { accessor_->Add(data_, &value); }
void RemoveLast() const { accessor_->RemoveLast(data_); }
// TODO: Remove.
ABSL_DEPRECATED("Do not use. Will be removed in a future release.")
void Reserve(int size) const { accessor_->Reserve(data_, size); }
void SwapElements(int index1, int index2) const {
accessor_->SwapElements(data_, index1, index2);
Expand Down Expand Up @@ -303,6 +308,8 @@ class PROTOBUF_EXPORT RepeatedFieldAccessor {
virtual void Set(Field* data, int index, const Value* value) const = 0;
virtual void Add(Field* data, const Value* value) const = 0;
virtual void RemoveLast(Field* data) const = 0;
// TODO: Remove.
ABSL_DEPRECATED("Do not use. Will be removed in a future release.")
virtual void Reserve(Field* data, int size) const = 0;
virtual void SwapElements(Field* data, int index1, int index2) const = 0;
virtual void Swap(Field* data, const RepeatedFieldAccessor* other_mutator,
Expand Down
2 changes: 2 additions & 0 deletions src/google/protobuf/reflection_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class RepeatedFieldWrapper : public RandomAccessRepeatedFieldAccessor {
void RemoveLast(Field* data) const override {
MutableRepeatedField(data)->RemoveLast();
}
// TODO: Remove.
void Reserve(Field* data, int size) const override {
MutableRepeatedField(data)->Reserve(size);
}
Expand Down Expand Up @@ -146,6 +147,7 @@ class RepeatedPtrFieldWrapper : public RandomAccessRepeatedFieldAccessor {
void RemoveLast(Field* data) const override {
MutableRepeatedField(data)->RemoveLast();
}
// TODO: Remove.
void Reserve(Field* data, int size) const override {
MutableRepeatedField(data)->Reserve(size);
}
Expand Down

0 comments on commit 7fc92a8

Please sign in to comment.