MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / repeat

Method repeat

modules/gui/gui/src/backend/text_server/ustring.cpp:4181–4200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4179}
4180
4181String 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
4202String String::left(int p_len) const
4203{

Callers 1

Calls 4

memcpyFunction · 0.85
lengthFunction · 0.50
resizeMethod · 0.45
ptrwMethod · 0.45

Tested by

no test coverage detected