FastLED 3.10.9
Loading...
Searching...
No Matches

◆ reserve()

void fl::basic_string::reserve ( fl::size newCapacity)

Definition at line 513 of file basic_string.cpp.hpp.

513 {
514 if (newCapacity <= mLength) return;
515 if (newCapacity + 1 <= mInlineCapacity) return;
516 if (hasHeapData()) {
518 if (heap.get().use_count() <= 1) {
519 if (!heap->hasCapacity(newCapacity)) {
520 heap->grow(newCapacity);
521 // grow updates holder length to the allocation length, but
522 // reserve must retain the original string and its terminator.
523 if (heap->hasCapacity(mLength)) {
524 heap->data()[mLength] = '\0';
525 }
526 }
527 return;
528 }
529 }
531 if (!newData->hasCapacity(newCapacity)) {
532 return;
533 }
534 fl::memcpy(newData->data(), c_str(), mLength);
535 newData->data()[mLength] = '\0';
536 mStorage = newData;
537}
NotNullStringHolderPtr & heapData() FL_NO_EXCEPT
bool hasHeapData() const FL_NO_EXCEPT
fl::size mInlineCapacity
fl::variant< NotNullStringHolderPtr, ConstLiteral, ConstView > mStorage
const char * c_str() const FL_NO_EXCEPT
shared_ptr< T > make_shared(Args &&... args) FL_NO_EXCEPT
Definition shared_ptr.h:423
fl::not_null< StringHolderPtr > NotNullStringHolderPtr
FASTLED_FORCE_INLINE void * memcpy(void *dest, const void *src, size_t n) FL_NO_EXCEPT
Definition cstring.h:136

References c_str(), fl::FL_NO_EXCEPT, fl::not_null< T >::get(), hasHeapData(), heapData(), fl::adl_barrier::make_shared(), fl::memcpy(), mInlineCapacity, mLength, mStorage, and fl::shared_ptr< T >::use_count().

Referenced by fl::base64_encode(), fl::formatJsonResponse(), and resize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: