MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / repeat

Method repeat

core/string/ustring.cpp:4182–4207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4180}
4181
4182String String::repeat(int p_count) const {
4183 ERR_FAIL_COND_V_MSG(p_count < 0, "", "Parameter count should be a positive number.");
4184
4185 if (p_count == 0) {
4186 return "";
4187 }
4188
4189 if (p_count == 1) {
4190 return *this;
4191 }
4192
4193 int len = length();
4194 String new_string = *this;
4195 new_string.resize_uninitialized(p_count * len + 1);
4196
4197 char32_t *dst = new_string.ptrw();
4198 int offset = 1;
4199 int stride = 1;
4200 while (offset < p_count) {
4201 memcpy(dst + offset * len, dst, stride * len * sizeof(char32_t));
4202 offset += stride;
4203 stride = MIN(stride * 2, p_count - offset);
4204 }
4205 dst[p_count * len] = _null;
4206 return new_string;
4207}
4208
4209String String::reverse() const {
4210 int len = length();

Callers 15

_html_submittedMethod · 0.80
_shape_lineMethod · 0.80
_shapeMethod · 0.80
_draw_guidelinesMethod · 0.80
set_indent_sizeMethod · 0.80
do_indentMethod · 0.80
indent_linesMethod · 0.80
_get_indentationMethod · 0.80
parse_doc_commentMethod · 0.80
_get_indentationMethod · 0.80

Calls 3

MINFunction · 0.85
resize_uninitializedMethod · 0.45
ptrwMethod · 0.45

Tested by 2

test_tokenizerFunction · 0.64
test_tokenizer_bufferFunction · 0.64