| 342 | // ======= COPY ======= |
| 343 | |
| 344 | void basic_string::copy(const char* str) { |
| 345 | fl::size len = fl::strlen(str); |
| 346 | mLength = len; |
| 347 | if (len + 1 <= mInlineCapacity) { |
| 348 | if (!isInline()) { |
| 349 | mStorage.reset(); |
| 350 | } |
| 351 | fl::memcpy(inlineBufferPtr(), str, len + 1); |
| 352 | } else { |
| 353 | if (hasHeapData() && heapData().get().use_count() <= 1) { |
| 354 | heapData()->copy(str, len); |
| 355 | return; |
| 356 | } |
| 357 | mStorage = NotNullStringHolderPtr(fl::make_shared<StringHolder>(str)); |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | void basic_string::copy(const char* str, fl::size len) { |
| 362 | mLength = len; |