protobuf/src/google/protobuf/repeated_field.h
Go to the documentation of this file.
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 // * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 // Author: kenton@google.com (Kenton Varda)
32 // Based on original Protocol Buffers design by
33 // Sanjay Ghemawat, Jeff Dean, and others.
34 //
35 // RepeatedField and RepeatedPtrField are used by generated protocol message
36 // classes to manipulate repeated fields. These classes are very similar to
37 // STL's vector, but include a number of optimizations found to be useful
38 // specifically in the case of Protocol Buffers. RepeatedPtrField is
39 // particularly different from STL vector as it manages ownership of the
40 // pointers that it contains.
41 //
42 // Typically, clients should not need to access RepeatedField objects directly,
43 // but should instead use the accessor functions generated automatically by the
44 // protocol compiler.
45 //
46 // This header covers RepeatedField.
47 
48 #ifndef GOOGLE_PROTOBUF_REPEATED_FIELD_H__
49 #define GOOGLE_PROTOBUF_REPEATED_FIELD_H__
50 
51 #include <utility>
52 #ifdef _MSC_VER
53 // This is required for min/max on VS2013 only.
54 #include <algorithm>
55 #endif
56 
57 #include <iterator>
58 #include <limits>
59 #include <string>
60 #include <type_traits>
61 
62 #include <google/protobuf/stubs/logging.h>
63 #include <google/protobuf/stubs/common.h>
65 #include <google/protobuf/arena.h>
66 #include <google/protobuf/message_lite.h>
67 #include <google/protobuf/port.h>
68 
69 
70 // Must be included last.
71 #include <google/protobuf/port_def.inc>
72 
73 #ifdef SWIG
74 #error "You cannot SWIG proto headers"
75 #endif
76 
77 namespace google {
78 namespace protobuf {
79 
80 class Message;
81 
82 namespace internal {
83 
84 // kRepeatedFieldLowerClampLimit is the smallest size that will be allocated
85 // when growing a repeated field.
87 
88 // kRepeatedFieldUpperClampLimit is the lowest signed integer value that
89 // overflows when multiplied by 2 (which is undefined behavior). Sizes above
90 // this will clamp to the maximum int value instead of following exponential
91 // growth when growing a repeated field.
94 
95 template <typename Iter>
96 inline int CalculateReserve(Iter begin, Iter end, std::forward_iterator_tag) {
97  return static_cast<int>(std::distance(begin, end));
98 }
99 
100 template <typename Iter>
101 inline int CalculateReserve(Iter /*begin*/, Iter /*end*/,
102  std::input_iterator_tag /*unused*/) {
103  return -1;
104 }
105 
106 template <typename Iter>
107 inline int CalculateReserve(Iter begin, Iter end) {
108  typedef typename std::iterator_traits<Iter>::iterator_category Category;
109  return CalculateReserve(begin, end, Category());
110 }
111 
112 // Swaps two blocks of memory of size sizeof(T).
113 template <typename T>
114 inline void SwapBlock(char* p, char* q) {
115  T tmp;
116  memcpy(&tmp, p, sizeof(T));
117  memcpy(p, q, sizeof(T));
118  memcpy(q, &tmp, sizeof(T));
119 }
120 
121 // Swaps two blocks of memory of size kSize:
122 // template <int kSize> void memswap(char* p, char* q);
123 
124 template <int kSize>
125 inline typename std::enable_if<(kSize == 0), void>::type memswap(char*, char*) {
126 }
127 
128 #define PROTO_MEMSWAP_DEF_SIZE(reg_type, max_size) \
129  template <int kSize> \
130  typename std::enable_if<(kSize >= sizeof(reg_type) && kSize < (max_size)), \
131  void>::type \
132  memswap(char* p, char* q) { \
133  SwapBlock<reg_type>(p, q); \
134  memswap<kSize - sizeof(reg_type)>(p + sizeof(reg_type), \
135  q + sizeof(reg_type)); \
136  }
137 
141 
142 #ifdef __SIZEOF_INT128__
144 PROTO_MEMSWAP_DEF_SIZE(__uint128_t, (1u << 31))
145 #else
146 PROTO_MEMSWAP_DEF_SIZE(uint64_t, (1u << 31))
147 #endif
148 
149 #undef PROTO_MEMSWAP_DEF_SIZE
150 
151 } // namespace internal
152 
153 // RepeatedField is used to represent repeated fields of a primitive type (in
154 // other words, everything except strings and nested Messages). Most users will
155 // not ever use a RepeatedField directly; they will use the get-by-index,
156 // set-by-index, and add accessors that are generated for all repeated fields.
157 template <typename Element>
158 class RepeatedField final {
159  static_assert(
160  alignof(Arena) >= alignof(Element),
161  "We only support types that have an alignment smaller than Arena");
162 
163  public:
164  constexpr RepeatedField();
165  explicit RepeatedField(Arena* arena);
166 
167  RepeatedField(const RepeatedField& other);
168 
169  template <typename Iter,
170  typename = typename std::enable_if<std::is_constructible<
171  Element, decltype(*std::declval<Iter>())>::value>::type>
173 
174  ~RepeatedField();
175 
176  RepeatedField& operator=(const RepeatedField& other);
177 
178  RepeatedField(RepeatedField&& other) noexcept;
179  RepeatedField& operator=(RepeatedField&& other) noexcept;
180 
181  bool empty() const;
182  int size() const;
183 
184  const Element& Get(int index) const;
185  Element* Mutable(int index);
186 
187  const Element& operator[](int index) const { return Get(index); }
188  Element& operator[](int index) { return *Mutable(index); }
189 
190  const Element& at(int index) const;
191  Element& at(int index);
192 
193  void Set(int index, const Element& value);
194  void Add(const Element& value);
195  // Appends a new element and return a pointer to it.
196  // The new element is uninitialized if |Element| is a POD type.
197  Element* Add();
198  // Append elements in the range [begin, end) after reserving
199  // the appropriate number of elements.
200  template <typename Iter>
201  void Add(Iter begin, Iter end);
202 
203  // Remove the last element in the array.
204  void RemoveLast();
205 
206  // Extract elements with indices in "[start .. start+num-1]".
207  // Copy them into "elements[0 .. num-1]" if "elements" is not nullptr.
208  // Caution: implementation also moves elements with indices [start+num ..].
209  // Calling this routine inside a loop can cause quadratic behavior.
210  void ExtractSubrange(int start, int num, Element* elements);
211 
212  PROTOBUF_ATTRIBUTE_REINITIALIZES void Clear();
213  void MergeFrom(const RepeatedField& other);
214  PROTOBUF_ATTRIBUTE_REINITIALIZES void CopyFrom(const RepeatedField& other);
215 
216  // Replaces the contents with RepeatedField(begin, end).
217  template <typename Iter>
218  PROTOBUF_ATTRIBUTE_REINITIALIZES void Assign(Iter begin, Iter end);
219 
220  // Reserve space to expand the field to at least the given size. If the
221  // array is grown, it will always be at least doubled in size.
222  void Reserve(int new_size);
223 
224  // Resize the RepeatedField to a new, smaller size. This is O(1).
225  void Truncate(int new_size);
226 
227  void AddAlreadyReserved(const Element& value);
228  // Appends a new element and return a pointer to it.
229  // The new element is uninitialized if |Element| is a POD type.
230  // Should be called only if Capacity() > Size().
231  Element* AddAlreadyReserved();
232  Element* AddNAlreadyReserved(int elements);
233  int Capacity() const;
234 
235  // Like STL resize. Uses value to fill appended elements.
236  // Like Truncate() if new_size <= size(), otherwise this is
237  // O(new_size - size()).
238  void Resize(int new_size, const Element& value);
239 
240  // Gets the underlying array. This pointer is possibly invalidated by
241  // any add or remove operation.
242  Element* mutable_data();
243  const Element* data() const;
244 
245  // Swap entire contents with "other". If they are separate arenas then, copies
246  // data between each other.
247  void Swap(RepeatedField* other);
248 
249  // Swap entire contents with "other". Should be called only if the caller can
250  // guarantee that both repeated fields are on the same arena or are on the
251  // heap. Swapping between different arenas is disallowed and caught by a
252  // GOOGLE_DCHECK (see API docs for details).
253  void UnsafeArenaSwap(RepeatedField* other);
254 
255  // Swap two elements.
256  void SwapElements(int index1, int index2);
257 
258  // STL-like iterator support
259  typedef Element* iterator;
260  typedef const Element* const_iterator;
261  typedef Element value_type;
263  typedef const value_type& const_reference;
264  typedef value_type* pointer;
265  typedef const value_type* const_pointer;
266  typedef int size_type;
267  typedef ptrdiff_t difference_type;
268 
269  iterator begin();
270  const_iterator begin() const;
271  const_iterator cbegin() const;
272  iterator end();
273  const_iterator end() const;
274  const_iterator cend() const;
275 
276  // Reverse iterator support
277  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
278  typedef std::reverse_iterator<iterator> reverse_iterator;
281  return const_reverse_iterator(end());
282  }
285  return const_reverse_iterator(begin());
286  }
287 
288  // Returns the number of bytes used by the repeated field, excluding
289  // sizeof(*this)
290  size_t SpaceUsedExcludingSelfLong() const;
291 
294  }
295 
296  // Removes the element referenced by position.
297  //
298  // Returns an iterator to the element immediately following the removed
299  // element.
300  //
301  // Invalidates all iterators at or after the removed element, including end().
303 
304  // Removes the elements in the range [first, last).
305  //
306  // Returns an iterator to the element immediately following the removed range.
307  //
308  // Invalidates all iterators at or after the removed range, including end().
310 
311  // Get the Arena on which this RepeatedField stores its elements.
312  inline Arena* GetArena() const {
313  return (total_size_ == 0) ? static_cast<Arena*>(arena_or_elements_)
314  : rep()->arena;
315  }
316 
317  // For internal use only.
318  //
319  // This is public due to it being called by generated code.
320  inline void InternalSwap(RepeatedField* other);
321 
322  private:
323  static constexpr int kInitialSize = 0;
324  // A note on the representation here (see also comment below for
325  // RepeatedPtrFieldBase's struct Rep):
326  //
327  // We maintain the same sizeof(RepeatedField) as before we added arena support
328  // so that we do not degrade performance by bloating memory usage. Directly
329  // adding an arena_ element to RepeatedField is quite costly. By using
330  // indirection in this way, we keep the same size when the RepeatedField is
331  // empty (common case), and add only an 8-byte header to the elements array
332  // when non-empty. We make sure to place the size fields directly in the
333  // RepeatedField class to avoid costly cache misses due to the indirection.
334  int current_size_;
335  int total_size_;
336  struct Rep {
337  Arena* arena;
338  // Here we declare a huge array as a way of approximating C's "flexible
339  // array member" feature without relying on undefined behavior.
340  Element elements[(std::numeric_limits<int>::max() - 2 * sizeof(Arena*)) /
341  sizeof(Element)];
342  };
343  static constexpr size_t kRepHeaderSize = offsetof(Rep, elements);
344 
345  // If total_size_ == 0 this points to an Arena otherwise it points to the
346  // elements member of a Rep struct. Using this invariant allows the storage of
347  // the arena pointer without an extra allocation in the constructor.
348  void* arena_or_elements_;
349 
350  // Return pointer to elements array.
351  // pre-condition: the array must have been allocated.
352  Element* elements() const {
354  // Because of above pre-condition this cast is safe.
355  return unsafe_elements();
356  }
357 
358  // Return pointer to elements array if it exists otherwise either null or
359  // a invalid pointer is returned. This only happens for empty repeated fields,
360  // where you can't dereference this pointer anyway (it's empty).
361  Element* unsafe_elements() const {
362  return static_cast<Element*>(arena_or_elements_);
363  }
364 
365  // Return pointer to the Rep struct.
366  // pre-condition: the Rep must have been allocated, ie elements() is safe.
367  Rep* rep() const {
368  char* addr = reinterpret_cast<char*>(elements()) - offsetof(Rep, elements);
369  return reinterpret_cast<Rep*>(addr);
370  }
371 
372  friend class Arena;
374 
375  // Move the contents of |from| into |to|, possibly clobbering |from| in the
376  // process. For primitive types this is just a memcpy(), but it could be
377  // specialized for non-primitive types to, say, swap each element instead.
378  void MoveArray(Element* to, Element* from, int size);
379 
380  // Copy the elements of |from| into |to|.
381  void CopyArray(Element* to, const Element* from, int size);
382 
383  // Internal helper to delete all elements and deallocate the storage.
384  void InternalDeallocate(Rep* rep, int size) {
385  if (rep != nullptr) {
386  Element* e = &rep->elements[0];
388  Element* limit = &rep->elements[size];
389  for (; e < limit; e++) {
390  e->~Element();
391  }
392  }
393  if (rep->arena == nullptr) {
394 #if defined(__GXX_DELETE_WITH_SIZE__) || defined(__cpp_sized_deallocation)
395  const size_t bytes = size * sizeof(*e) + kRepHeaderSize;
396  ::operator delete(static_cast<void*>(rep), bytes);
397 #else
398  ::operator delete(static_cast<void*>(rep));
399 #endif
400  }
401  }
402  }
403 
404  // This class is a performance wrapper around RepeatedField::Add(const T&)
405  // function. In general unless a RepeatedField is a local stack variable LLVM
406  // has a hard time optimizing Add. The machine code tends to be
407  // loop:
408  // mov %size, dword ptr [%repeated_field] // load
409  // cmp %size, dword ptr [%repeated_field + 4]
410  // jae fallback
411  // mov %buffer, qword ptr [%repeated_field + 8]
412  // mov dword [%buffer + %size * 4], %value
413  // inc %size // increment
414  // mov dword ptr [%repeated_field], %size // store
415  // jmp loop
416  //
417  // This puts a load/store in each iteration of the important loop variable
418  // size. It's a pretty bad compile that happens even in simple cases, but
419  // largely the presence of the fallback path disturbs the compilers mem-to-reg
420  // analysis.
421  //
422  // This class takes ownership of a repeated field for the duration of it's
423  // lifetime. The repeated field should not be accessed during this time, ie.
424  // only access through this class is allowed. This class should always be a
425  // function local stack variable. Intended use
426  //
427  // void AddSequence(const int* begin, const int* end, RepeatedField<int>* out)
428  // {
429  // RepeatedFieldAdder<int> adder(out); // Take ownership of out
430  // for (auto it = begin; it != end; ++it) {
431  // adder.Add(*it);
432  // }
433  // }
434  //
435  // Typically due to the fact adder is a local stack variable. The compiler
436  // will be successful in mem-to-reg transformation and the machine code will
437  // be loop: cmp %size, %capacity jae fallback mov dword ptr [%buffer + %size *
438  // 4], %val inc %size jmp loop
439  //
440  // The first version executes at 7 cycles per iteration while the second
441  // version near 1 or 2 cycles.
444  public:
449  }
451 
452  void Add(Element val) {
453  if (index_ == capacity_) {
458  }
459  buffer_[index_++] = val;
460  }
461 
462  private:
464  int index_;
466  Element* buffer_;
467 
469  };
470 
471  // FastAdder is a wrapper for adding fields. The specialization above handles
472  // POD types more efficiently than RepeatedField.
473  template <int I>
475  public:
477  void Add(const Element& val) { repeated_field_->Add(val); }
478 
479  private:
482  };
483 
484  using FastAdder = FastAdderImpl<>;
485 
487  friend class ::google::protobuf::internal::ParseContext;
488 };
489 
490 namespace internal {
491 
492 // This is a helper template to copy an array of elements efficiently when they
493 // have a trivial copy constructor, and correctly otherwise. This really
494 // shouldn't be necessary, but our compiler doesn't optimize std::copy very
495 // effectively.
496 template <typename Element,
497  bool HasTrivialCopy = std::is_trivial<Element>::value>
498 struct ElementCopier {
499  void operator()(Element* to, const Element* from, int array_size);
500 };
501 
502 } // namespace internal
503 
504 // implementation ====================================================
505 
506 template <typename Element>
508  : current_size_(0), total_size_(0), arena_or_elements_(nullptr) {}
509 
510 template <typename Element>
512  : current_size_(0), total_size_(0), arena_or_elements_(arena) {}
513 
514 template <typename Element>
516  : current_size_(0), total_size_(0), arena_or_elements_(nullptr) {
517  if (other.current_size_ != 0) {
518  Reserve(other.size());
519  AddNAlreadyReserved(other.size());
520  CopyArray(Mutable(0), &other.Get(0), other.size());
521  }
522 }
523 
524 template <typename Element>
525 template <typename Iter, typename>
527  : current_size_(0), total_size_(0), arena_or_elements_(nullptr) {
528  Add(begin, end);
529 }
530 
531 template <typename Element>
533 #ifndef NDEBUG
534  // Try to trigger segfault / asan failure in non-opt builds. If arena_
535  // lifetime has ended before the destructor.
536  auto arena = GetArena();
537  if (arena) (void)arena->SpaceAllocated();
538 #endif
539  if (total_size_ > 0) {
540  InternalDeallocate(rep(), total_size_);
541  }
542 }
543 
544 template <typename Element>
546  const RepeatedField& other) {
547  if (this != &other) CopyFrom(other);
548  return *this;
549 }
550 
551 template <typename Element>
553  : RepeatedField() {
554 #ifdef PROTOBUF_FORCE_COPY_IN_MOVE
555  CopyFrom(other);
556 #else // PROTOBUF_FORCE_COPY_IN_MOVE
557  // We don't just call Swap(&other) here because it would perform 3 copies if
558  // other is on an arena. This field can't be on an arena because arena
559  // construction always uses the Arena* accepting constructor.
560  if (other.GetArena()) {
561  CopyFrom(other);
562  } else {
563  InternalSwap(&other);
564  }
565 #endif // !PROTOBUF_FORCE_COPY_IN_MOVE
566 }
567 
568 template <typename Element>
570  RepeatedField&& other) noexcept {
571  // We don't just call Swap(&other) here because it would perform 3 copies if
572  // the two fields are on different arenas.
573  if (this != &other) {
574  if (GetArena() != other.GetArena()
575 #ifdef PROTOBUF_FORCE_COPY_IN_MOVE
576  || GetArena() == nullptr
577 #endif // !PROTOBUF_FORCE_COPY_IN_MOVE
578  ) {
579  CopyFrom(other);
580  } else {
581  InternalSwap(&other);
582  }
583  }
584  return *this;
585 }
586 
587 template <typename Element>
588 inline bool RepeatedField<Element>::empty() const {
589  return current_size_ == 0;
590 }
591 
592 template <typename Element>
593 inline int RepeatedField<Element>::size() const {
594  return current_size_;
595 }
596 
597 template <typename Element>
598 inline int RepeatedField<Element>::Capacity() const {
599  return total_size_;
600 }
601 
602 template <typename Element>
603 inline void RepeatedField<Element>::AddAlreadyReserved(const Element& value) {
604  GOOGLE_DCHECK_LT(current_size_, total_size_);
605  elements()[current_size_++] = value;
606 }
607 
608 template <typename Element>
610  GOOGLE_DCHECK_LT(current_size_, total_size_);
611  return &elements()[current_size_++];
612 }
613 
614 template <typename Element>
615 inline Element* RepeatedField<Element>::AddNAlreadyReserved(int n) {
616  GOOGLE_DCHECK_GE(total_size_ - current_size_, n)
617  << total_size_ << ", " << current_size_;
618  // Warning: sometimes people call this when n == 0 and total_size_ == 0. In
619  // this case the return pointer points to a zero size array (n == 0). Hence
620  // we can just use unsafe_elements(), because the user cannot dereference the
621  // pointer anyway.
622  Element* ret = unsafe_elements() + current_size_;
623  current_size_ += n;
624  return ret;
625 }
626 
627 template <typename Element>
628 inline void RepeatedField<Element>::Resize(int new_size, const Element& value) {
630  if (new_size > current_size_) {
631  Reserve(new_size);
632  std::fill(&elements()[current_size_], &elements()[new_size], value);
633  }
634  current_size_ = new_size;
635 }
636 
637 template <typename Element>
638 inline const Element& RepeatedField<Element>::Get(int index) const {
640  GOOGLE_DCHECK_LT(index, current_size_);
641  return elements()[index];
642 }
643 
644 template <typename Element>
645 inline const Element& RepeatedField<Element>::at(int index) const {
647  GOOGLE_CHECK_LT(index, current_size_);
648  return elements()[index];
649 }
650 
651 template <typename Element>
652 inline Element& RepeatedField<Element>::at(int index) {
654  GOOGLE_CHECK_LT(index, current_size_);
655  return elements()[index];
656 }
657 
658 template <typename Element>
659 inline Element* RepeatedField<Element>::Mutable(int index) {
661  GOOGLE_DCHECK_LT(index, current_size_);
662  return &elements()[index];
663 }
664 
665 template <typename Element>
666 inline void RepeatedField<Element>::Set(int index, const Element& value) {
668  GOOGLE_DCHECK_LT(index, current_size_);
669  elements()[index] = value;
670 }
671 
672 template <typename Element>
673 inline void RepeatedField<Element>::Add(const Element& value) {
674  uint32_t size = current_size_;
675  if (static_cast<int>(size) == total_size_) {
676  // value could reference an element of the array. Reserving new space will
677  // invalidate the reference. So we must make a copy first.
678  auto tmp = value;
679  Reserve(total_size_ + 1);
680  elements()[size] = std::move(tmp);
681  } else {
682  elements()[size] = value;
683  }
684  current_size_ = size + 1;
685 }
686 
687 template <typename Element>
688 inline Element* RepeatedField<Element>::Add() {
689  uint32_t size = current_size_;
690  if (static_cast<int>(size) == total_size_) Reserve(total_size_ + 1);
691  auto ptr = &elements()[size];
692  current_size_ = size + 1;
693  return ptr;
694 }
695 
696 template <typename Element>
697 template <typename Iter>
700  if (reserve != -1) {
701  if (reserve == 0) {
702  return;
703  }
704 
705  Reserve(reserve + size());
706  // TODO(ckennelly): The compiler loses track of the buffer freshly
707  // allocated by Reserve() by the time we call elements, so it cannot
708  // guarantee that elements does not alias [begin(), end()).
709  //
710  // If restrict is available, annotating the pointer obtained from elements()
711  // causes this to lower to memcpy instead of memmove.
712  std::copy(begin, end, elements() + size());
713  current_size_ = reserve + size();
714  } else {
715  FastAdder fast_adder(this);
716  for (; begin != end; ++begin) fast_adder.Add(*begin);
717  }
718 }
719 
720 template <typename Element>
722  GOOGLE_DCHECK_GT(current_size_, 0);
723  current_size_--;
724 }
725 
726 template <typename Element>
728  Element* elements) {
730  GOOGLE_DCHECK_GE(num, 0);
731  GOOGLE_DCHECK_LE(start + num, this->current_size_);
732 
733  // Save the values of the removed elements if requested.
734  if (elements != nullptr) {
735  for (int i = 0; i < num; ++i) elements[i] = this->Get(i + start);
736  }
737 
738  // Slide remaining elements down to fill the gap.
739  if (num > 0) {
740  for (int i = start + num; i < this->current_size_; ++i)
741  this->Set(i - num, this->Get(i));
742  this->Truncate(this->current_size_ - num);
743  }
744 }
745 
746 template <typename Element>
747 inline void RepeatedField<Element>::Clear() {
748  current_size_ = 0;
749 }
750 
751 template <typename Element>
752 inline void RepeatedField<Element>::MergeFrom(const RepeatedField& other) {
753  GOOGLE_DCHECK_NE(&other, this);
754  if (other.current_size_ != 0) {
755  int existing_size = size();
756  Reserve(existing_size + other.size());
757  AddNAlreadyReserved(other.size());
758  CopyArray(Mutable(existing_size), &other.Get(0), other.size());
759  }
760 }
761 
762 template <typename Element>
763 inline void RepeatedField<Element>::CopyFrom(const RepeatedField& other) {
764  if (&other == this) return;
765  Clear();
766  MergeFrom(other);
767 }
768 
769 template <typename Element>
770 template <typename Iter>
772  Clear();
773  Add(begin, end);
774 }
775 
776 template <typename Element>
778  const_iterator position) {
779  return erase(position, position + 1);
780 }
781 
782 template <typename Element>
784  const_iterator first, const_iterator last) {
785  size_type first_offset = first - cbegin();
786  if (first != last) {
787  Truncate(std::copy(last, cend(), begin() + first_offset) - cbegin());
788  }
789  return begin() + first_offset;
790 }
791 
792 template <typename Element>
793 inline Element* RepeatedField<Element>::mutable_data() {
794  return unsafe_elements();
795 }
796 
797 template <typename Element>
798 inline const Element* RepeatedField<Element>::data() const {
799  return unsafe_elements();
800 }
801 
802 template <typename Element>
804  GOOGLE_DCHECK(this != other);
805 
806  // Swap all fields at once.
807  static_assert(std::is_standard_layout<RepeatedField<Element>>::value,
808  "offsetof() requires standard layout before c++17");
809  internal::memswap<offsetof(RepeatedField, arena_or_elements_) +
810  sizeof(this->arena_or_elements_) -
811  offsetof(RepeatedField, current_size_)>(
812  reinterpret_cast<char*>(this) + offsetof(RepeatedField, current_size_),
813  reinterpret_cast<char*>(other) + offsetof(RepeatedField, current_size_));
814 }
815 
816 template <typename Element>
818  if (this == other) return;
819 #ifdef PROTOBUF_FORCE_COPY_IN_SWAP
820  if (GetArena() != nullptr && GetArena() == other->GetArena()) {
821 #else // PROTOBUF_FORCE_COPY_IN_SWAP
822  if (GetArena() == other->GetArena()) {
823 #endif // !PROTOBUF_FORCE_COPY_IN_SWAP
824  InternalSwap(other);
825  } else {
826  RepeatedField<Element> temp(other->GetArena());
827  temp.MergeFrom(*this);
828  CopyFrom(*other);
829  other->UnsafeArenaSwap(&temp);
830  }
831 }
832 
833 template <typename Element>
835  if (this == other) return;
836  InternalSwap(other);
837 }
838 
839 template <typename Element>
840 void RepeatedField<Element>::SwapElements(int index1, int index2) {
841  using std::swap; // enable ADL with fallback
842  swap(elements()[index1], elements()[index2]);
843 }
844 
845 template <typename Element>
846 inline typename RepeatedField<Element>::iterator
848  return unsafe_elements();
849 }
850 template <typename Element>
853  return unsafe_elements();
854 }
855 template <typename Element>
858  return unsafe_elements();
859 }
860 template <typename Element>
862  return unsafe_elements() + current_size_;
863 }
864 template <typename Element>
867  return unsafe_elements() + current_size_;
868 }
869 template <typename Element>
872  return unsafe_elements() + current_size_;
873 }
874 
875 template <typename Element>
877  return total_size_ > 0 ? (total_size_ * sizeof(Element) + kRepHeaderSize) : 0;
878 }
879 
880 namespace internal {
881 // Returns the new size for a reserved field based on its 'total_size' and the
882 // requested 'new_size'. The result is clamped to the closed interval:
883 // [internal::kMinRepeatedFieldAllocationSize,
884 // std::numeric_limits<int>::max()]
885 // Requires:
886 // new_size > total_size &&
887 // (total_size == 0 ||
888 // total_size >= kRepeatedFieldLowerClampLimit)
889 inline int CalculateReserveSize(int total_size, int new_size) {
891  // Clamp to smallest allowed size.
893  }
894  if (total_size < kRepeatedFieldUpperClampLimit) {
895  return std::max(total_size * 2, new_size);
896  } else {
897  // Clamp to largest allowed size.
900  }
901 }
902 } // namespace internal
903 
904 // Avoid inlining of Reserve(): new, copy, and delete[] lead to a significant
905 // amount of code bloat.
906 template <typename Element>
908  if (total_size_ >= new_size) return;
909  Rep* old_rep = total_size_ > 0 ? rep() : nullptr;
910  Rep* new_rep;
911  Arena* arena = GetArena();
914  static_cast<size_t>(new_size),
915  (std::numeric_limits<size_t>::max() - kRepHeaderSize) / sizeof(Element))
916  << "Requested size is too large to fit into size_t.";
917  size_t bytes =
918  kRepHeaderSize + sizeof(Element) * static_cast<size_t>(new_size);
919  if (arena == nullptr) {
920  new_rep = static_cast<Rep*>(::operator new(bytes));
921  } else {
922  new_rep = reinterpret_cast<Rep*>(Arena::CreateArray<char>(arena, bytes));
923  }
924  new_rep->arena = arena;
925  int old_total_size = total_size_;
926  // Already known: new_size >= internal::kMinRepeatedFieldAllocationSize
927  // Maintain invariant:
928  // total_size_ == 0 ||
929  // total_size_ >= internal::kMinRepeatedFieldAllocationSize
930  total_size_ = new_size;
931  arena_or_elements_ = new_rep->elements;
932  // Invoke placement-new on newly allocated elements. We shouldn't have to do
933  // this, since Element is supposed to be POD, but a previous version of this
934  // code allocated storage with "new Element[size]" and some code uses
935  // RepeatedField with non-POD types, relying on constructor invocation. If
936  // Element has a trivial constructor (e.g., int32_t), gcc (tested with -O2)
937  // completely removes this loop because the loop body is empty, so this has no
938  // effect unless its side-effects are required for correctness.
939  // Note that we do this before MoveArray() below because Element's copy
940  // assignment implementation will want an initialized instance first.
941  Element* e = &elements()[0];
942  Element* limit = e + total_size_;
943  for (; e < limit; e++) {
944  new (e) Element;
945  }
946  if (current_size_ > 0) {
947  MoveArray(&elements()[0], old_rep->elements, current_size_);
948  }
949 
950  // Likewise, we need to invoke destructors on the old array.
951  InternalDeallocate(old_rep, old_total_size);
952 
953 }
954 
955 template <typename Element>
957  GOOGLE_DCHECK_LE(new_size, current_size_);
958  if (current_size_ > 0) {
959  current_size_ = new_size;
960  }
961 }
962 
963 template <typename Element>
964 inline void RepeatedField<Element>::MoveArray(Element* to, Element* from,
965  int array_size) {
966  CopyArray(to, from, array_size);
967 }
968 
969 template <typename Element>
970 inline void RepeatedField<Element>::CopyArray(Element* to, const Element* from,
971  int array_size) {
972  internal::ElementCopier<Element>()(to, from, array_size);
973 }
974 
975 namespace internal {
976 
977 template <typename Element, bool HasTrivialCopy>
978 void ElementCopier<Element, HasTrivialCopy>::operator()(Element* to,
979  const Element* from,
980  int array_size) {
981  std::copy(from, from + array_size, to);
982 }
983 
984 template <typename Element>
985 struct ElementCopier<Element, true> {
986  void operator()(Element* to, const Element* from, int array_size) {
987  memcpy(to, from, static_cast<size_t>(array_size) * sizeof(Element));
988  }
989 };
990 
991 } // namespace internal
992 
993 
994 // -------------------------------------------------------------------
995 
996 // Iterators and helper functions that follow the spirit of the STL
997 // std::back_insert_iterator and std::back_inserter but are tailor-made
998 // for RepeatedField and RepeatedPtrField. Typical usage would be:
999 //
1000 // std::copy(some_sequence.begin(), some_sequence.end(),
1001 // RepeatedFieldBackInserter(proto.mutable_sequence()));
1002 //
1003 // Ported by johannes from util/gtl/proto-array-iterators.h
1004 
1005 namespace internal {
1006 // A back inserter for RepeatedField objects.
1007 template <typename T>
1008 class RepeatedFieldBackInsertIterator {
1009  public:
1010  using iterator_category = std::output_iterator_tag;
1011  using value_type = T;
1012  using pointer = void;
1013  using reference = void;
1014  using difference_type = std::ptrdiff_t;
1015 
1017  RepeatedField<T>* const mutable_field)
1018  : field_(mutable_field) {}
1020  field_->Add(value);
1021  return *this;
1022  }
1026  return *this;
1027  }
1028 
1029  private:
1030  RepeatedField<T>* field_;
1031 };
1032 
1033 } // namespace internal
1034 
1035 // Provides a back insert iterator for RepeatedField instances,
1036 // similar to std::back_inserter().
1037 template <typename T>
1038 internal::RepeatedFieldBackInsertIterator<T> RepeatedFieldBackInserter(
1039  RepeatedField<T>* const mutable_field) {
1040  return internal::RepeatedFieldBackInsertIterator<T>(mutable_field);
1041 }
1042 
1043 // Extern declarations of common instantiations to reduce library bloat.
1044 extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<bool>;
1045 extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<int32_t>;
1046 extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<uint32_t>;
1047 extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<int64_t>;
1048 extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<uint64_t>;
1049 extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<float>;
1050 extern template class PROTOBUF_EXPORT_TEMPLATE_DECLARE RepeatedField<double>;
1051 
1052 } // namespace protobuf
1053 } // namespace google
1054 
1055 #include <google/protobuf/port_undef.inc>
1056 
1057 #endif // GOOGLE_PROTOBUF_REPEATED_FIELD_H__
ptr
char * ptr
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:45
google::protobuf::RepeatedField::FastAdderImpl::index_
int index_
Definition: protobuf/src/google/protobuf/repeated_field.h:464
google::protobuf::RepeatedField::TestRepeatedFieldHelper
friend class TestRepeatedFieldHelper
Definition: protobuf/src/google/protobuf/repeated_field.h:486
fix_build_deps.temp
temp
Definition: fix_build_deps.py:488
GOOGLE_DCHECK_NE
#define GOOGLE_DCHECK_NE
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:197
absl::swap_internal::Swap
void Swap(T &lhs, T &rhs) noexcept(IsNothrowSwappable< T >::value)
Definition: abseil-cpp/absl/meta/type_traits.h:772
google::protobuf::RepeatedField::cbegin
const_iterator cbegin() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1368
google::protobuf::RepeatedField::FastAdderImpl::GOOGLE_DISALLOW_EVIL_CONSTRUCTORS
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FastAdderImpl)
google::protobuf.internal::GetArena
Arena * GetArena(MessageLite *msg, int64 arena_offset)
Definition: bloaty/third_party/protobuf/src/google/protobuf/generated_message_table_driven_lite.h:86
google::protobuf::value
const Descriptor::ReservedRange value
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:1954
google::protobuf::RepeatedField::kInitialSize
static const int kInitialSize
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:269
google::protobuf::RepeatedField::elements
Element * elements() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:299
google::protobuf::RepeatedField::size_type
int size_type
Definition: protobuf/src/google/protobuf/repeated_field.h:266
google::protobuf::RepeatedField::arena_or_elements_
void * arena_or_elements_
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:295
google::protobuf::RepeatedField::FastAdderImpl::FastAdderImpl
FastAdderImpl(RepeatedField *rf)
Definition: protobuf/src/google/protobuf/repeated_field.h:445
google::protobuf::RepeatedField::value_type
Element value_type
Definition: protobuf/src/google/protobuf/repeated_field.h:261
reserve
static bool reserve(upb_pb_encoder *e, size_t bytes)
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/upb.c:7630
google::protobuf::RepeatedField::cend
const_iterator cend() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1382
begin
char * begin
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1007
false
#define false
Definition: setup_once.h:323
uint16_t
unsigned short uint16_t
Definition: stdint-msvc2008.h:79
google::protobuf.internal.python_message.MergeFrom
MergeFrom
Definition: bloaty/third_party/protobuf/python/google/protobuf/internal/python_message.py:1339
google::protobuf.internal::ElementCopier::operator()
void operator()(Element *to, const Element *from, int array_size)
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1462
google::protobuf::RepeatedField::empty
bool empty() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1125
position
intern position
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/array.c:487
google::protobuf::RepeatedField::ExtractSubrange
void ExtractSubrange(int start, int num, Element *elements)
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1253
GOOGLE_DCHECK
#define GOOGLE_DCHECK
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:194
google::protobuf::RepeatedField::end
iterator end()
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1372
copy
static int copy(grpc_slice_buffer *input, grpc_slice_buffer *output)
Definition: message_compress.cc:145
google::protobuf::RepeatedField::rend
reverse_iterator rend()
Definition: protobuf/src/google/protobuf/repeated_field.h:283
google::protobuf::python::cmessage::CopyFrom
static PyObject * CopyFrom(CMessage *self, PyObject *arg)
Definition: bloaty/third_party/protobuf/python/google/protobuf/pyext/message.cc:1862
google::protobuf::RepeatedField::FastAdderImpl< I, false >::Add
void Add(const Element &val)
Definition: protobuf/src/google/protobuf/repeated_field.h:477
Arena
Definition: arena.c:39
google::protobuf::RepeatedField::SpaceUsedExcludingSelf
int SpaceUsedExcludingSelf() const
Definition: protobuf/src/google/protobuf/repeated_field.h:292
google::protobuf::RepeatedField::data
const Element * data() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1317
binary_size.new_size
def new_size
Definition: binary_size.py:124
GOOGLE_CHECK_LT
#define GOOGLE_CHECK_LT(A, B)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:158
google::protobuf::RepeatedField::FastAdderImpl::Add
void Add(Element val)
Definition: protobuf/src/google/protobuf/repeated_field.h:452
google::protobuf
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:12
google::protobuf::RepeatedField::Rep::arena
Arena * arena
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:283
google::protobuf::RepeatedField
Definition: bloaty/third_party/protobuf/src/google/protobuf/message.h:184
to
size_t to
Definition: abseil-cpp/absl/container/internal/layout_test.cc:1385
google::protobuf::python::cdescriptor_pool::Add
static PyObject * Add(PyObject *self, PyObject *file_descriptor_proto)
Definition: bloaty/third_party/protobuf/python/google/protobuf/pyext/descriptor_pool.cc:621
google::protobuf::RepeatedField::operator[]
Element & operator[](int index)
Definition: protobuf/src/google/protobuf/repeated_field.h:188
repeated_ptr_field.h
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
google::protobuf::RepeatedField::Add
void Add(const Element &value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1210
google::protobuf::RepeatedField::erase
iterator erase(const_iterator position)
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1296
google::protobuf::RepeatedField::Clear
void Clear()
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1273
T
#define T(upbtypeconst, upbtype, ctype, default_value)
GOOGLE_DCHECK_LT
#define GOOGLE_DCHECK_LT
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:198
true
#define true
Definition: setup_once.h:324
google::protobuf::RepeatedField::FastAdderImpl::repeated_field_
RepeatedField * repeated_field_
Definition: protobuf/src/google/protobuf/repeated_field.h:463
arena
grpc_core::ScopedArenaPtr arena
Definition: binder_transport_test.cc:237
RepeatedField::size
int size
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.h:407
absl::synchronization_internal::Get
static GraphId Get(const IdMap &id, int num)
Definition: abseil-cpp/absl/synchronization/internal/graphcycles_test.cc:44
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
google::protobuf::RepeatedField::kRepHeaderSize
static const size_t kRepHeaderSize
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:290
google::protobuf::RepeatedField::const_reverse_iterator
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: protobuf/src/google/protobuf/repeated_field.h:277
from
size_t from
Definition: abseil-cpp/absl/container/internal/layout_test.cc:1384
gen_gtest_pred_impl.Iter
def Iter(n, format, sep='')
Definition: bloaty/third_party/googletest/googletest/scripts/gen_gtest_pred_impl.py:188
google::protobuf::RepeatedField::operator[]
const Element & operator[](int index) const
Definition: protobuf/src/google/protobuf/repeated_field.h:187
google::protobuf::RepeatedField::reverse_iterator
std::reverse_iterator< iterator > reverse_iterator
Definition: protobuf/src/google/protobuf/repeated_field.h:278
memcpy
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
google::protobuf::RepeatedField::Capacity
int Capacity() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1135
google::protobuf::RepeatedField::FastAdderImpl
Definition: protobuf/src/google/protobuf/repeated_field.h:443
google::protobuf::RepeatedField::mutable_data
Element * mutable_data()
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1312
start
static uint64_t start
Definition: benchmark-pound.c:74
absl::FormatConversionChar::e
@ e
google::protobuf::RepeatedField::Truncate
void Truncate(int new_size)
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1440
absl::move
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
Definition: abseil-cpp/absl/utility/utility.h:221
end
char * end
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1008
RepeatedField
struct RepeatedField RepeatedField
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:667
swap
#define swap(a, b)
Definition: qsort.h:111
max
int max
Definition: bloaty/third_party/zlib/examples/enough.c:170
google::protobuf.internal::CalculateReserveSize
int CalculateReserveSize(int total_size, int new_size)
Definition: protobuf/src/google/protobuf/repeated_field.h:889
GOOGLE_DCHECK_GT
#define GOOGLE_DCHECK_GT
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:200
google::protobuf::RepeatedField::Assign
PROTOBUF_ATTRIBUTE_REINITIALIZES void Assign(Iter begin, Iter end)
google::protobuf::RepeatedField::FastAdderImpl< I, false >::repeated_field_
RepeatedField * repeated_field_
Definition: protobuf/src/google/protobuf/repeated_field.h:480
google::protobuf::RepeatedField::difference_type
ptrdiff_t difference_type
Definition: protobuf/src/google/protobuf/repeated_field.h:267
google::protobuf::RepeatedField::InternalSwap
void InternalSwap(RepeatedField *other)
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1322
google::protobuf.internal::ToIntSize
int ToIntSize(size_t size)
Definition: bloaty/third_party/protobuf/src/google/protobuf/message_lite.h:105
GOOGLE_CHECK_GE
#define GOOGLE_CHECK_GE(A, B)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:161
google::protobuf.internal::kRepeatedFieldUpperClampLimit
constexpr int kRepeatedFieldUpperClampLimit
Definition: protobuf/src/google/protobuf/repeated_field.h:92
google::protobuf::RepeatedField::FastAdderImpl< I, false >::FastAdderImpl
FastAdderImpl(RepeatedField *rf)
Definition: protobuf/src/google/protobuf/repeated_field.h:476
uint64_t
unsigned __int64 uint64_t
Definition: stdint-msvc2008.h:90
google::protobuf::RepeatedField::UnsafeArenaSwap
void UnsafeArenaSwap(RepeatedField *other)
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1345
google::protobuf::RepeatedField::pointer
value_type * pointer
Definition: protobuf/src/google/protobuf/repeated_field.h:264
google::protobuf::RepeatedField::AddAlreadyReserved
Element * AddAlreadyReserved()
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1146
google::protobuf::RepeatedField::Resize
void Resize(int new_size, const Element &value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1165
GOOGLE_DCHECK_GE
#define GOOGLE_DCHECK_GE
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:201
google::protobuf.internal::memswap
std::enable_if<(kSize==0), void >::type memswap(char *, char *)
Definition: protobuf/src/google/protobuf/repeated_field.h:125
google::protobuf::RepeatedField::at
const Element & at(int index) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1182
std::swap
void swap(Json::Value &a, Json::Value &b)
Specialize std::swap() for Json::Value.
Definition: third_party/bloaty/third_party/protobuf/conformance/third_party/jsoncpp/json.h:1226
google::protobuf.internal::RepeatedFieldBackInsertIterator::pointer
void pointer
Definition: protobuf/src/google/protobuf/repeated_field.h:1012
google::protobuf::RepeatedField::reference
value_type & reference
Definition: protobuf/src/google/protobuf/repeated_field.h:262
google::protobuf::RepeatedField::FastAdderImpl::capacity_
int capacity_
Definition: protobuf/src/google/protobuf/repeated_field.h:465
data
char data[kBufferLength]
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1006
google::protobuf::RepeatedField::Rep::elements
Element elements[1]
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:284
google::protobuf::RepeatedField::rbegin
reverse_iterator rbegin()
Definition: protobuf/src/google/protobuf/repeated_field.h:279
google::protobuf::RepeatedField::const_iterator
const typedef Element * const_iterator
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:209
n
int n
Definition: abseil-cpp/absl/container/btree_test.cc:1080
google::protobuf::RepeatedField::AddNAlreadyReserved
Element * AddNAlreadyReserved(int elements)
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1152
google_benchmark.example.empty
def empty(state)
Definition: example.py:31
google::protobuf.internal::RepeatedFieldBackInsertIterator::reference
void reference
Definition: protobuf/src/google/protobuf/repeated_field.h:1013
google::protobuf::RepeatedField::RemoveLast
void RemoveLast()
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1247
google::protobuf::RepeatedField::MoveArray
void MoveArray(Element *to, Element *from, int size)
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1448
google::protobuf::RepeatedField::GetArena
Arena * GetArena() const
Definition: protobuf/src/google/protobuf/repeated_field.h:312
value
const char * value
Definition: hpack_parser_table.cc:165
google::protobuf.internal::RepeatedFieldBackInsertIterator::iterator_category
std::output_iterator_tag iterator_category
Definition: protobuf/src/google/protobuf/repeated_field.h:1010
google::protobuf::RepeatedField::CopyFrom
void CopyFrom(const RepeatedField &other)
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1289
google::protobuf.internal::RepeatedFieldBackInsertIterator::operator++
RepeatedFieldBackInsertIterator< T > & operator++()
Definition: protobuf/src/google/protobuf/repeated_field.h:1024
google::protobuf.internal::CalculateReserve
int CalculateReserve(Iter begin, Iter end, std::forward_iterator_tag)
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:94
google::protobuf::RepeatedField::const_pointer
const typedef value_type * const_pointer
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:214
google::protobuf::RepeatedField::operator=
RepeatedField & operator=(const RepeatedField &other)
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1090
google::protobuf.internal::ElementCopier< Element, true >::operator()
void operator()(Element *to, const Element *from, int array_size)
Definition: protobuf/src/google/protobuf/repeated_field.h:986
google::protobuf::RepeatedField::begin
iterator begin()
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1358
google::protobuf::RepeatedField::CopyArray
void CopyArray(Element *to, const Element *from, int size)
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1454
google::protobuf::RepeatedField::Set
void Set(int index, const Element &value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1203
I
#define I(b, c, d)
Definition: md5.c:120
bytes
uint8 bytes[10]
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream_unittest.cc:153
google::protobuf::RepeatedFieldBackInserter
internal::RepeatedFieldBackInsertIterator< T > RepeatedFieldBackInserter(RepeatedField< T > *const mutable_field)
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:2605
google::protobuf.internal.python_message.Clear
Clear
Definition: bloaty/third_party/protobuf/python/google/protobuf/internal/python_message.py:1430
google::protobuf::RepeatedField::FastAdderImpl::buffer_
Element * buffer_
Definition: protobuf/src/google/protobuf/repeated_field.h:466
google::protobuf::RepeatedField::iterator
Element * iterator
Definition: protobuf/src/google/protobuf/repeated_field.h:259
index
int index
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:1184
google::protobuf::RepeatedField::InternalDeallocate
void InternalDeallocate(Rep *rep, int size)
Definition: protobuf/src/google/protobuf/repeated_field.h:384
ret
UniquePtr< SSL_SESSION > ret
Definition: ssl_x509.cc:1029
google::protobuf::RepeatedField::rend
const_reverse_iterator rend() const
Definition: protobuf/src/google/protobuf/repeated_field.h:284
google::protobuf::RepeatedField::total_size_
int total_size_
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:281
first
StrT first
Definition: cxa_demangle.cpp:4884
google::protobuf::RepeatedField::size
int size() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1130
testing::internal::CopyArray
void CopyArray(const T *from, size_t size, U *to)
Definition: bloaty/third_party/googletest/googletest/include/gtest/internal/gtest-internal.h:1036
xds_manager.num
num
Definition: xds_manager.py:56
rep
const CordRep * rep
Definition: cord_analysis.cc:53
google::protobuf::RepeatedField::RepeatedField
RepeatedField()
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1058
google::protobuf::RepeatedField< uint64_t >::FastAdder
FastAdderImpl<> FastAdder
Definition: protobuf/src/google/protobuf/repeated_field.h:484
google::protobuf.internal::RepeatedFieldBackInsertIterator::difference_type
std::ptrdiff_t difference_type
Definition: protobuf/src/google/protobuf/repeated_field.h:1014
fill
int fill
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:47
google::protobuf.internal::RepeatedFieldBackInsertIterator::operator++
RepeatedFieldBackInsertIterator< T > & operator++(int)
Definition: protobuf/src/google/protobuf/repeated_field.h:1025
google::protobuf.internal::RepeatedFieldBackInsertIterator::value_type
T value_type
Definition: protobuf/src/google/protobuf/repeated_field.h:1011
google::protobuf::RepeatedField::rep
Rep * rep() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:314
google::protobuf::RepeatedField::Swap
void Swap(RepeatedField *other)
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1332
internal
Definition: benchmark/test/output_test_helper.cc:20
google::protobuf::RepeatedField::Get
const Element & Get(int index) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1175
google::protobuf.internal::kRepeatedFieldLowerClampLimit
constexpr int kRepeatedFieldLowerClampLimit
Definition: protobuf/src/google/protobuf/repeated_field.h:86
google::protobuf::RepeatedField::current_size_
int current_size_
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:280
google::protobuf::RepeatedField::rbegin
const_reverse_iterator rbegin() const
Definition: protobuf/src/google/protobuf/repeated_field.h:280
google::protobuf.internal::SwapBlock
void SwapBlock(char *p, char *q)
Definition: protobuf/src/google/protobuf/repeated_field.h:114
asyncio_get_stats.type
type
Definition: asyncio_get_stats.py:37
autogen_x86imm.tmp
tmp
Definition: autogen_x86imm.py:12
google::protobuf::RepeatedField::const_reference
const typedef value_type & const_reference
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:212
google::protobuf::RepeatedField::InternalArenaConstructable_
void InternalArenaConstructable_
Definition: protobuf/src/google/protobuf/repeated_field.h:373
size
voidpf void uLong size
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136
PROTO_MEMSWAP_DEF_SIZE
#define PROTO_MEMSWAP_DEF_SIZE(reg_type, max_size)
Definition: protobuf/src/google/protobuf/repeated_field.h:128
google::protobuf.internal::RepeatedFieldBackInsertIterator::operator=
RepeatedFieldBackInsertIterator< T > & operator=(const T &value)
Definition: protobuf/src/google/protobuf/repeated_field.h:1019
google::protobuf::RepeatedField::MergeFrom
void MergeFrom(const RepeatedField &other)
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1278
testing::Assign
PolymorphicAction< internal::AssignAction< T1, T2 > > Assign(T1 *ptr, T2 val)
Definition: bloaty/third_party/googletest/googlemock/include/gmock/gmock-actions.h:1061
google::protobuf::RepeatedField::Add
Element * Add()
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1216
GOOGLE_DCHECK_LE
#define GOOGLE_DCHECK_LE
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:199
google::protobuf.internal::RepeatedFieldBackInsertIterator::operator*
RepeatedFieldBackInsertIterator< T > & operator*()
Definition: protobuf/src/google/protobuf/repeated_field.h:1023
google::protobuf::RepeatedField::Mutable
Element * Mutable(int index)
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1196
google::protobuf::RepeatedField::SpaceUsedExcludingSelfLong
size_t SpaceUsedExcludingSelfLong() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1387
addr
struct sockaddr_in addr
Definition: libuv/docs/code/tcp-echo-server/main.c:10
google
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:11
google::protobuf.internal::RepeatedFieldBackInsertIterator::RepeatedFieldBackInsertIterator
RepeatedFieldBackInsertIterator(RepeatedField< T > *const mutable_field)
Definition: protobuf/src/google/protobuf/repeated_field.h:1016
google::protobuf::RepeatedField::Reserve
void Reserve(int new_size)
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1394
google::protobuf::RepeatedField::unsafe_elements
Element * unsafe_elements() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:308
google::protobuf.internal::RepeatedFieldBackInsertIterator
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:2497
Message
Definition: protobuf/php/ext/google/protobuf/message.c:53
google::protobuf::RepeatedField::SwapElements
void SwapElements(int index1, int index2)
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1351
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
google::protobuf::RepeatedField::FastAdderImpl::~FastAdderImpl
~FastAdderImpl()
Definition: protobuf/src/google/protobuf/repeated_field.h:450
google::protobuf::RepeatedField::~RepeatedField
~RepeatedField()
Definition: bloaty/third_party/protobuf/src/google/protobuf/repeated_field.h:1083
RepeatedField
Definition: bloaty/third_party/protobuf/ruby/ext/google/protobuf_c/protobuf.h:403


grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:03