Skip to content

Commit

Permalink
Breaking change: Remove MutableRepeatedFieldRef::Reserve() in refle…
Browse files Browse the repository at this point in the history
…ction (roll forward)

An upcoming performance improvement in RepeatedPtrField is incompatible with this API. The improvement is projected to accelerate repeated access to the elements of `RepeatedPtrField`, in particular and especially sequential access.

PA: https://protobuf.dev/news/2024-12-13/
PiperOrigin-RevId: 708439051
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Dec 20, 2024
1 parent 259e2ba commit 913f7b0
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 26 deletions.
9 changes: 0 additions & 9 deletions src/google/protobuf/reflection.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,6 @@ 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 @@ -218,9 +215,6 @@ 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 @@ -308,9 +302,6 @@ 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,
Field* other_data) const = 0;
Expand Down
11 changes: 0 additions & 11 deletions src/google/protobuf/reflection_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ 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);
}
void SwapElements(Field* data, int index1, int index2) const override {
MutableRepeatedField(data)->SwapElements(index1, index2);
}
Expand Down Expand Up @@ -153,10 +149,6 @@ 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);
}
void SwapElements(Field* data, int index1, int index2) const override {
MutableRepeatedField(data)->SwapElements(index1, index2);
}
Expand Down Expand Up @@ -220,9 +212,6 @@ class MapFieldAccessor final : public RandomAccessRepeatedFieldAccessor {
void RemoveLast(Field* data) const override {
MutableRepeatedField(data)->RemoveLast();
}
void Reserve(Field* data, int size) const override {
MutableRepeatedField(data)->Reserve(size);
}
void SwapElements(Field* data, int index1, int index2) const override {
MutableRepeatedField(data)->SwapElements(index1, index2);
}
Expand Down
6 changes: 0 additions & 6 deletions src/google/protobuf/repeated_field_reflection_unittest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,6 @@ TEST(REFLECTION_TEST, RepeatedFieldRefForRegularFields) {
}
EXPECT_EQ(10, index);

// Test MutableRepeatedFieldRef::Reserve()
mrf_int32.Reserve(mrf_int32.size() + 1);
mrf_double.Reserve(mrf_double.size() + 1);
mrf_string.Reserve(mrf_string.size() + 1);
mrf_foreign_message.Reserve(mrf_foreign_message.size() + 1);

// Test MutableRepeatedFieldRef::Add()
mrf_int32.Add(1234);
mrf_double.Add(1234.0);
Expand Down

0 comments on commit 913f7b0

Please sign in to comment.