Deprecate ClearedCount

This will be removed in a future release along with the rest of the "cleared" API

PiperOrigin-RevId: 504344009
pull/11648/head
Mike Kruskal 2 years ago committed by Copybara-Service
parent 43e5937bf6
commit b39f77efa8
  1. 4
      src/google/protobuf/repeated_field_unittest.cc
  2. 2
      src/google/protobuf/repeated_ptr_field.h

@ -1514,6 +1514,7 @@ TEST(RepeatedPtrField, ReserveDoesntLoseAllocated) {
// Clearing elements is tricky with RepeatedPtrFields since the memory for
// the elements is retained and reused.
TEST(RepeatedPtrField, ClearedElements) {
PROTOBUF_IGNORE_DEPRECATION_START
RepeatedPtrField<std::string> field;
std::string* original = field.Add();
@ -1540,7 +1541,6 @@ TEST(RepeatedPtrField, ClearedElements) {
field.Clear();
EXPECT_EQ(field.ClearedCount(), 2);
#ifndef PROTOBUF_FUTURE_REMOVE_CLEARED_API
PROTOBUF_IGNORE_DEPRECATION_START
EXPECT_EQ(field.ReleaseCleared(), original); // Take ownership again.
EXPECT_EQ(field.ClearedCount(), 1);
EXPECT_NE(field.Add(), original);
@ -1552,8 +1552,8 @@ TEST(RepeatedPtrField, ClearedElements) {
EXPECT_EQ(field.ClearedCount(), 1);
EXPECT_EQ(field.Add(), original);
EXPECT_EQ(field.ClearedCount(), 0);
PROTOBUF_IGNORE_DEPRECATION_STOP
#endif // !PROTOBUF_FUTURE_REMOVE_CLEARED_API
PROTOBUF_IGNORE_DEPRECATION_STOP
}
// Test all code paths in AddAllocated().

@ -1144,7 +1144,9 @@ class RepeatedPtrField final : private internal::RepeatedPtrFieldBase {
// Gets the number of cleared objects that are currently being kept
// around for reuse.
ABSL_DEPRECATED("This will be removed in a future release")
int ClearedCount() const;
#ifndef PROTOBUF_FUTURE_REMOVE_CLEARED_API
// Adds an element to the pool of cleared objects, passing ownership to
// the RepeatedPtrField. The element must be cleared prior to calling

Loading…
Cancel
Save