311 }
else if (other.count() == 1) {
312 this->push_back(other.back());
319 int headItemCount = 0;
323 int headStart = First(headBlock);
324 int headEnd = Last(headBlock) +
sizeof(
T);
325 headItemCount = (headEnd - headStart) /
sizeof(
T);
326 int avail = fAllocator->currentBlock()->template avail<alignof(T)>() /
sizeof(
T);
327 if (headItemCount > avail) {
331 fAllocator->template reserve<alignof(T)>((headItemCount - avail) *
sizeof(
T),
336 if constexpr (std::is_trivially_copy_constructible<T>::value) {
338 SkASSERT(std::is_trivially_destructible<T>::value);
340 auto target = dst->template allocate<alignof(T)>(n *
sizeof(
T));
342 target.fBlock->setMetadata(
target.fAlignedOffset + (n - 1) *
sizeof(
T));
347 copy(headBlock, headStart, fAllocator.allocator(), std::min(headItemCount, avail));
349 if (headItemCount > avail) {
351 copy(headBlock, headStart + avail *
sizeof(
T),
352 fAllocator.allocator(), headItemCount - avail);
354 fAllocator->setMetadata(fAllocator->metadata() + headItemCount);
357 for (
int i = headStart; i < headEnd; i +=
sizeof(
T)) {
358 T& toMove = GetItem(headBlock, i);
359 this->push_back(std::move(toMove));
366 other.fAllocator->releaseBlock(headBlock);
370 SkASSERT(other.fAllocator->headBlock()->metadata() == 0 &&
371 fAllocator->metadata() == oldCount + headItemCount);
372 fAllocator->stealHeapBlocks(other.fAllocator.allocator());
373 fAllocator->setMetadata(fAllocator->metadata() +
374 (other.fAllocator->metadata() - headItemCount));
375 other.fAllocator->setMetadata(0);
BlockIndexIterator< const T &, false, true, &Last, &First, &Decrement, &GetItem > CRIter
BlockIndexIterator< const T &, true, true, &First, &Last, &Increment, &GetItem > CIter