MCPcopy Create free account
hub / github.com/FastLED/FastLED / shrink_to_fit

Method shrink_to_fit

src/fl/stl/basic_string.cpp.hpp:500–514  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

498}
499
500void basic_string::shrink_to_fit() {
501 if (hasHeapData()) {
502 NotNullStringHolderPtr& heap = heapData();
503 if (heap.get().use_count() > 1) return;
504 if (heap->capacity() <= mLength + 1) return;
505 if (mLength + 1 <= mInlineCapacity) {
506 fl::memcpy(inlineBufferPtr(), heap->data(), mLength + 1);
507 mStorage.reset();
508 return;
509 }
510 NotNullStringHolderPtr newData = NotNullStringHolderPtr(fl::make_shared<StringHolder>(mLength));
511 fl::memcpy(newData->data(), heap->data(), mLength + 1);
512 mStorage = newData;
513 }
514}
515
516// ======= FIND =======
517

Callers

nothing calls this directly

Calls 6

memcpyFunction · 0.50
use_countMethod · 0.45
getMethod · 0.45
capacityMethod · 0.45
dataMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected