Add String::remove_char(s) methods for performance and convenience

This commit is contained in:
A Thousand Ships 2024-05-28 12:55:07 +02:00
parent cae3d722a3
commit 331a43a9d8
No known key found for this signature in database
GPG key ID: DEFC5A5B1306947D
35 changed files with 221 additions and 54 deletions

View file

@ -2249,7 +2249,7 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
switch (expression_pattern) {
case RGBA_PARAMETER: {
color_args = line.substr(begin, end - begin);
String stripped = color_args.replace(" ", "").replace("\t", "").replace("(", "").replace(")", "");
String stripped = color_args.remove_chars(" \t()");
PackedFloat64Array color = stripped.split_floats(",");
if (color.size() > 2) {
float alpha = color.size() > 3 ? color[3] : 1.0f;
@ -2261,7 +2261,7 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) {
end = line.length();
}
color_args = line.substr(begin, end - begin);
const String color_name = color_args.replace(" ", "").replace("\t", "").replace(".", "");
const String color_name = color_args.remove_chars(" \t.");
const int color_index = Color::find_named_color(color_name);
if (0 <= color_index) {
const Color color_constant = Color::get_named_color(color_index);