| 568 | } |
| 569 | |
| 570 | void StringImpl::Insert(intptr idx, const char* str, intptr length) |
| 571 | { |
| 572 | BF_ASSERT(idx >= 0); |
| 573 | |
| 574 | int_strsize newLength = mLength + (int_strsize)length; |
| 575 | if (newLength >= GetAllocSize()) |
| 576 | { |
| 577 | intptr newSize = max((int_strsize)GetAllocSize() * 2, newLength + 1); |
| 578 | Realloc(newSize); |
| 579 | } |
| 580 | |
| 581 | auto moveChars = mLength - idx; |
| 582 | auto ptr = GetMutablePtr(); |
| 583 | if (moveChars > 0) |
| 584 | memmove(ptr + idx + length, ptr + idx, moveChars); |
| 585 | memcpy(ptr + idx, str, length); |
| 586 | mLength = newLength; |
| 587 | ptr[mLength] = 0; |
| 588 | } |
| 589 | |
| 590 | void StringImpl::Insert(intptr idx, const StringImpl& addString) |
| 591 | { |
no test coverage detected