Use String.repeat() in more places

This commit is contained in:
VolTer 2023-01-29 00:52:05 +01:00
parent 10d22a4b35
commit 6b84e258d2
12 changed files with 37 additions and 94 deletions

View file

@ -3040,12 +3040,7 @@ String GDScriptLanguage::_get_indentation() const {
if (use_space_indentation) {
int indent_size = EDITOR_GET("text_editor/behavior/indent/size");
String space_indent = "";
for (int i = 0; i < indent_size; i++) {
space_indent += " ";
}
return space_indent;
return String(" ").repeat(indent_size);
}
}
#endif
@ -3092,12 +3087,7 @@ void GDScriptLanguage::auto_indent_code(String &p_code, int p_from_line, int p_t
}
if (i >= p_from_line) {
l = "";
for (int j = 0; j < indent_stack.size(); j++) {
l += indent;
}
l += st;
l = indent.repeat(indent_stack.size()) + st;
} else if (i > p_to_line) {
break;
}

View file

@ -6839,9 +6839,9 @@ PackedByteArray GLTFDocument::_serialize_glb_buffer(Ref<GLTFState> p_state, Erro
const int32_t header_size = 12;
const int32_t chunk_header_size = 8;
for (int32_t pad_i = 0; pad_i < (chunk_header_size + json.utf8().length()) % 4; pad_i++) {
json += " ";
}
int32_t padding = (chunk_header_size + json.utf8().length()) % 4;
json += String(" ").repeat(padding);
CharString cs = json.utf8();
const uint32_t text_chunk_length = cs.length();

View file

@ -524,12 +524,7 @@ String CSharpLanguage::_get_indentation() const {
if (use_space_indentation) {
int indent_size = EDITOR_GET("text_editor/behavior/indent/size");
String space_indent = "";
for (int i = 0; i < indent_size; i++) {
space_indent += " ";
}
return space_indent;
return String(" ").repeat(indent_size);
}
}
#endif