| 473 | // ======= MEMORY MANAGEMENT ======= |
| 474 | |
| 475 | void basic_string::reserve(fl::size newCapacity) { |
| 476 | if (newCapacity <= mLength) return; |
| 477 | if (newCapacity + 1 <= mInlineCapacity) return; |
| 478 | if (hasHeapData()) { |
| 479 | const NotNullStringHolderPtr& heap = heapData(); |
| 480 | if (heap.get().use_count() <= 1 && heap->hasCapacity(newCapacity)) { |
| 481 | return; |
| 482 | } |
| 483 | } |
| 484 | NotNullStringHolderPtr newData = NotNullStringHolderPtr(fl::make_shared<StringHolder>(newCapacity)); |
| 485 | fl::memcpy(newData->data(), c_str(), mLength); |
| 486 | newData->data()[mLength] = '\0'; |
| 487 | mStorage = newData; |
| 488 | } |
| 489 | |
| 490 | void basic_string::clear(bool freeMemory) { |
| 491 | mLength = 0; |
nothing calls this directly
no test coverage detected