Delete obsolete function.

`WeakRepeatedPtrField::AddWeak` is not used anywhere, hence deleting it and related code in `RepeatedPtrField`.

PiperOrigin-RevId: 579830701
pull/14586/head
Protobuf Team Bot 1 year ago committed by Copybara-Service
parent e32d0948e7
commit 08ec050c44
  1. 3
      src/google/protobuf/implicit_weak_message.h
  2. 29
      src/google/protobuf/repeated_ptr_field.cc
  3. 9
      src/google/protobuf/repeated_ptr_field.h

@ -187,9 +187,6 @@ struct WeakRepeatedPtrField {
return const_pointer_iterator(base().raw_data() + base().size());
}
MessageLite* AddWeak(const MessageLite* prototype) {
return base().AddWeak(prototype);
}
T* Add() { return weak.Add(); }
void Clear() { base().template Clear<TypeHandler>(); }
void MergeFrom(const WeakRepeatedPtrField& other) {

@ -108,24 +108,6 @@ void RepeatedPtrFieldBase::DestroyProtos() {
tagged_rep_or_elem_ = nullptr;
}
void* RepeatedPtrFieldBase::AddOutOfLineHelper(void* obj) {
if (tagged_rep_or_elem_ == nullptr) {
ABSL_DCHECK_EQ(current_size_, 0);
ABSL_DCHECK(using_sso());
ABSL_DCHECK_EQ(allocated_size(), 0);
ExchangeCurrentSize(1);
return tagged_rep_or_elem_ = obj;
}
// Not using `AllocatedSizeAtCapacity` because it's already known that
// `tagged_rep_or_elem_ != nullptr`.
if (using_sso() || rep()->allocated_size >= Capacity()) {
InternalExtend(1); // Equivalent to "Reserve(total_size_ + 1)"
}
Rep* r = rep();
++r->allocated_size;
return r->elements[ExchangeCurrentSize(current_size_ + 1)] = obj;
}
template <typename F>
auto* RepeatedPtrFieldBase::AddInternal(F factory) {
using Result = decltype(factory(GetArena()));
@ -180,17 +162,6 @@ MessageLite* RepeatedPtrFieldBase::AddMessage(const MessageLite* prototype) {
return AddInternal([prototype](Arena* a) { return prototype->New(a); });
}
MessageLite* RepeatedPtrFieldBase::AddWeak(const MessageLite* prototype) {
if (current_size_ < allocated_size()) {
return reinterpret_cast<MessageLite*>(
element_at(ExchangeCurrentSize(current_size_ + 1)));
}
MessageLite* result = prototype
? prototype->New(arena_)
: Arena::CreateMessage<ImplicitWeakMessage>(arena_);
return static_cast<MessageLite*>(AddOutOfLineHelper(result));
}
void InternalOutOfLineDeleteMessageLite(MessageLite* message) {
delete message;
}

@ -294,11 +294,6 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
// Pre-condition: prototype must not be nullptr.
MessageLite* AddMessage(const MessageLite* prototype);
// This method is similar to `AddMessage` except that prototype may be nullptr
// in which case an ImplicitWeakMessage will be used as a placeholder. It is
// used to implement implicit weak fields.
MessageLite* AddWeak(const MessageLite* prototype);
template <typename TypeHandler>
void Clear() {
const int n = current_size_;
@ -838,10 +833,6 @@ class PROTOBUF_EXPORT RepeatedPtrFieldBase {
return InternalExtend(n - Capacity());
}
// Internal helper for Add: adds "obj" as the next element in the
// array, including potentially resizing the array with Reserve if
// needed
void* AddOutOfLineHelper(void* obj);
// Internal helper for Add that keeps definition out-of-line.
void* AddOutOfLineHelper(ElementFactory factory);

Loading…
Cancel
Save