diff options
author | A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> | 2024-11-16 18:52:15 +0100 |
---|---|---|
committer | A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> | 2024-11-17 10:02:18 +0100 |
commit | 68f638cf02cc595872c1a35b78cb1ce0039b1eef (patch) | |
tree | 311896361f77ee440b3bfd4c5b2f19f344f88333 /scene/resources | |
parent | 5efd124ca10bf46df62fa2441d80589777e54a5a (diff) | |
download | redot-engine-68f638cf02cc595872c1a35b78cb1ce0039b1eef.tar.gz |
Use `(r)find_char` instead of `(r)find` for single characters
Diffstat (limited to 'scene/resources')
-rw-r--r-- | scene/resources/font.cpp | 8 | ||||
-rw-r--r-- | scene/resources/mesh.cpp | 4 | ||||
-rw-r--r-- | scene/resources/packed_scene.cpp | 14 | ||||
-rw-r--r-- | scene/resources/resource_format_text.cpp | 2 | ||||
-rw-r--r-- | scene/resources/syntax_highlighter.cpp | 4 |
5 files changed, 16 insertions, 16 deletions
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index a4677d917d..ae70443e6a 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -1734,7 +1734,7 @@ Error FontFile::_load_bitmap_font(const String &p_path, List<String> *r_image_fi while (true) { String line = f->get_line(); - int delimiter = line.find(" "); + int delimiter = line.find_char(' '); String type = line.substr(0, delimiter); int pos = delimiter + 1; HashMap<String, String> keys; @@ -1744,7 +1744,7 @@ Error FontFile::_load_bitmap_font(const String &p_path, List<String> *r_image_fi } while (pos < line.size()) { - int eq = line.find("=", pos); + int eq = line.find_char('=', pos); if (eq == -1) { break; } @@ -1752,14 +1752,14 @@ Error FontFile::_load_bitmap_font(const String &p_path, List<String> *r_image_fi int end = -1; String value; if (line[eq + 1] == '"') { - end = line.find("\"", eq + 2); + end = line.find_char('"', eq + 2); if (end == -1) { break; } value = line.substr(eq + 2, end - 1 - eq - 1); pos = end + 1; } else { - end = line.find(" ", eq + 1); + end = line.find_char(' ', eq + 1); if (end == -1) { end = line.size(); } diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index b0353b4f2c..8c0e087902 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -1315,7 +1315,7 @@ bool ArrayMesh::_set(const StringName &p_name, const Variant &p_value) { String sname = p_name; if (sname.begins_with("surface_")) { - int sl = sname.find("/"); + int sl = sname.find_char('/'); if (sl == -1) { return false; } @@ -1708,7 +1708,7 @@ bool ArrayMesh::_get(const StringName &p_name, Variant &r_ret) const { String sname = p_name; if (sname.begins_with("surface_")) { - int sl = sname.find("/"); + int sl = sname.find_char('/'); if (sl == -1) { return false; } diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp index 809a77a487..d7036fd6d5 100644 --- a/scene/resources/packed_scene.cpp +++ b/scene/resources/packed_scene.cpp @@ -822,10 +822,10 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Has value = missing_resource_properties[E.name]; } } else if (E.type == Variant::ARRAY && E.hint == PROPERTY_HINT_TYPE_STRING) { - int hint_subtype_separator = E.hint_string.find(":"); + int hint_subtype_separator = E.hint_string.find_char(':'); if (hint_subtype_separator >= 0) { String subtype_string = E.hint_string.substr(0, hint_subtype_separator); - int slash_pos = subtype_string.find("/"); + int slash_pos = subtype_string.find_char('/'); PropertyHint subtype_hint = PropertyHint::PROPERTY_HINT_NONE; if (slash_pos >= 0) { subtype_hint = PropertyHint(subtype_string.get_slice("/", 1).to_int()); @@ -851,11 +851,11 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Has } } } else if (E.type == Variant::DICTIONARY && E.hint == PROPERTY_HINT_TYPE_STRING) { - int key_value_separator = E.hint_string.find(";"); + int key_value_separator = E.hint_string.find_char(';'); if (key_value_separator >= 0) { - int key_subtype_separator = E.hint_string.find(":"); + int key_subtype_separator = E.hint_string.find_char(':'); String key_subtype_string = E.hint_string.substr(0, key_subtype_separator); - int key_slash_pos = key_subtype_string.find("/"); + int key_slash_pos = key_subtype_string.find_char('/'); PropertyHint key_subtype_hint = PropertyHint::PROPERTY_HINT_NONE; if (key_slash_pos >= 0) { key_subtype_hint = PropertyHint(key_subtype_string.get_slice("/", 1).to_int()); @@ -864,9 +864,9 @@ Error SceneState::_parse_node(Node *p_owner, Node *p_node, int p_parent_idx, Has Variant::Type key_subtype = Variant::Type(key_subtype_string.to_int()); bool convert_key = key_subtype == Variant::OBJECT && key_subtype_hint == PROPERTY_HINT_NODE_TYPE; - int value_subtype_separator = E.hint_string.find(":", key_value_separator) - (key_value_separator + 1); + int value_subtype_separator = E.hint_string.find_char(':', key_value_separator) - (key_value_separator + 1); String value_subtype_string = E.hint_string.substr(key_value_separator + 1, value_subtype_separator); - int value_slash_pos = value_subtype_string.find("/"); + int value_slash_pos = value_subtype_string.find_char('/'); PropertyHint value_subtype_hint = PropertyHint::PROPERTY_HINT_NONE; if (value_slash_pos >= 0) { value_subtype_hint = PropertyHint(value_subtype_string.get_slice("/", 1).to_int()); diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp index 6e03fe25c9..03f0e107e4 100644 --- a/scene/resources/resource_format_text.cpp +++ b/scene/resources/resource_format_text.cpp @@ -1782,7 +1782,7 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const Ref<Reso for (KeyValue<Ref<Resource>, String> &E : external_resources) { String cached_id = E.key->get_id_for_path(local_path); if (cached_id.is_empty() || cached_ids_found.has(cached_id)) { - int sep_pos = E.value.find("_"); + int sep_pos = E.value.find_char('_'); if (sep_pos != -1) { E.value = E.value.substr(0, sep_pos + 1); // Keep the order found, for improved thread loading performance. } else { diff --git a/scene/resources/syntax_highlighter.cpp b/scene/resources/syntax_highlighter.cpp index da90ba1ef2..4bc03a049a 100644 --- a/scene/resources/syntax_highlighter.cpp +++ b/scene/resources/syntax_highlighter.cpp @@ -205,7 +205,7 @@ Dictionary CodeHighlighter::_get_line_syntax_highlighting_impl(int p_line) { if (end_key_length == 0 || color_regions[c].line_only || from + end_key_length > line_length) { if (from + end_key_length > line_length && (color_regions[in_region].start_key == "\"" || color_regions[in_region].start_key == "\'")) { // If it's key length and there is a '\', dont skip to highlight esc chars. - if (str.find("\\", from) >= 0) { + if (str.find_char('\\', from) >= 0) { break; } } @@ -242,7 +242,7 @@ Dictionary CodeHighlighter::_get_line_syntax_highlighting_impl(int p_line) { for (; from < line_length; from++) { if (line_length - from < end_key_length) { // Don't break if '\' to highlight esc chars. - if (!is_string || str.find("\\", from) < 0) { + if (!is_string || str.find_char('\\', from) < 0) { break; } } |