| 4179 | } |
| 4180 | |
| 4181 | String String::repeat(int p_count) const |
| 4182 | { |
| 4183 | ERR_FAIL_COND_V_MSG(p_count < 0, "", "Parameter count should be a positive number."); |
| 4184 | |
| 4185 | int len = length(); |
| 4186 | String new_string = *this; |
| 4187 | new_string.resize(p_count * len + 1); |
| 4188 | |
| 4189 | char32_t* dst = new_string.ptrw(); |
| 4190 | int offset = 1; |
| 4191 | int stride = 1; |
| 4192 | while (offset < p_count) |
| 4193 | { |
| 4194 | memcpy(dst + offset * len, dst, stride * len * sizeof(char32_t)); |
| 4195 | offset += stride; |
| 4196 | stride = MIN(stride * 2, p_count - offset); |
| 4197 | } |
| 4198 | dst[p_count * len] = _null; |
| 4199 | return new_string; |
| 4200 | } |
| 4201 | |
| 4202 | String String::left(int p_len) const |
| 4203 | { |
no test coverage detected