From 68f638cf02cc595872c1a35b78cb1ce0039b1eef Mon Sep 17 00:00:00 2001 From: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> Date: Sat, 16 Nov 2024 18:52:15 +0100 Subject: [PATCH] Use `(r)find_char` instead of `(r)find` for single characters --- core/config/project_settings.cpp | 8 ++-- core/debugger/engine_debugger.cpp | 2 +- core/debugger/local_debugger.cpp | 4 +- core/debugger/remote_debugger.cpp | 4 +- core/debugger/remote_debugger_peer.cpp | 2 +- core/input/input.cpp | 2 +- core/input/input_map.cpp | 4 +- core/io/dir_access.cpp | 4 +- core/io/http_client.cpp | 4 +- core/io/http_client_tcp.cpp | 4 +- core/io/plist.cpp | 8 ++-- core/io/resource_loader.cpp | 6 +-- core/io/translation_loader_po.cpp | 6 +-- core/string/node_path.cpp | 2 +- core/string/translation_po.cpp | 8 ++-- core/string/ustring.cpp | 40 +++++++++---------- drivers/alsa/audio_driver_alsa.cpp | 2 +- drivers/unix/os_unix.cpp | 2 +- drivers/windows/dir_access_windows.cpp | 4 +- drivers/windows/file_access_windows.cpp | 2 +- editor/animation_bezier_editor.cpp | 2 +- editor/animation_track_editor.cpp | 4 +- editor/connections_dialog.cpp | 2 +- editor/create_dialog.cpp | 4 +- .../debug_adapter/debug_adapter_parser.cpp | 2 +- editor/debugger/editor_debugger_node.cpp | 8 ++-- editor/debugger/editor_debugger_tree.cpp | 2 +- editor/dependency_editor.cpp | 2 +- editor/directory_create_dialog.cpp | 2 +- editor/editor_asset_installer.cpp | 8 ++-- editor/editor_folding.cpp | 2 +- editor/editor_help.cpp | 8 ++-- editor/editor_inspector.cpp | 10 ++--- editor/editor_node.cpp | 4 +- editor/editor_properties_array_dict.cpp | 12 +++--- editor/editor_sectioned_inspector.cpp | 4 +- editor/engine_update_label.cpp | 4 +- editor/filesystem_dock.cpp | 8 ++-- editor/gui/editor_file_dialog.cpp | 4 +- editor/import/resource_importer_imagefont.cpp | 2 +- editor/localization_editor.cpp | 6 +-- .../plugins/asset_library_editor_plugin.cpp | 2 +- editor/plugins/script_text_editor.cpp | 4 +- editor/project_converter_3_to_4.cpp | 6 +-- editor/script_create_dialog.cpp | 2 +- editor/shader_create_dialog.cpp | 2 +- main/main.cpp | 4 +- modules/gdscript/editor/gdscript_docgen.cpp | 2 +- .../gdscript/editor/gdscript_highlighter.cpp | 4 +- modules/gdscript/gdscript_editor.cpp | 2 +- .../editor/editor_scene_importer_blend.cpp | 4 +- modules/gltf/gltf_document.cpp | 2 +- modules/mono/csharp_script.cpp | 2 +- modules/mono/editor/bindings_generator.cpp | 24 +++++------ modules/mono/editor/code_completion.cpp | 2 +- modules/mono/utils/path_utils.cpp | 2 +- .../multiplayer/editor/replication_editor.cpp | 4 +- modules/svg/image_loader_svg.cpp | 2 +- platform/android/export/export_plugin.cpp | 2 +- platform/macos/export/export_plugin.cpp | 4 +- platform/web/api/web_tools_editor_plugin.cpp | 2 +- scene/gui/file_dialog.cpp | 4 +- scene/gui/rich_text_label.cpp | 2 +- scene/main/http_request.cpp | 2 +- scene/property_utils.cpp | 2 +- scene/resources/font.cpp | 8 ++-- scene/resources/mesh.cpp | 4 +- scene/resources/packed_scene.cpp | 14 +++---- scene/resources/resource_format_text.cpp | 2 +- scene/resources/syntax_highlighter.cpp | 4 +- 70 files changed, 169 insertions(+), 169 deletions(-) diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index fa0e4037ba3..9b2efd89e18 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -194,7 +194,7 @@ String ProjectSettings::localize_path(const String &p_path) const { return cwd.replace_first(res_path, "res://"); } else { - int sep = path.rfind("/"); + int sep = path.rfind_char('/'); if (sep == -1) { return "res://" + path; } @@ -300,7 +300,7 @@ bool ProjectSettings::_set(const StringName &p_name, const Variant &p_value) { } { // Feature overrides. - int dot = p_name.operator String().find("."); + int dot = p_name.operator String().find_char('.'); if (dot != -1) { Vector s = p_name.operator String().split("."); @@ -435,7 +435,7 @@ void ProjectSettings::_get_property_list(List *p_list) const { for (const _VCSort &E : vclist) { String prop_info_name = E.name; - int dot = prop_info_name.find("."); + int dot = prop_info_name.find_char('.'); if (dot != -1 && !custom_prop_info.has(prop_info_name)) { prop_info_name = prop_info_name.substr(0, dot); } @@ -1092,7 +1092,7 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust String category = E.name; String name = E.name; - int div = category.find("/"); + int div = category.find_char('/'); if (div < 0) { category = ""; diff --git a/core/debugger/engine_debugger.cpp b/core/debugger/engine_debugger.cpp index 6d2868cef2f..a9f87ad825f 100644 --- a/core/debugger/engine_debugger.cpp +++ b/core/debugger/engine_debugger.cpp @@ -163,7 +163,7 @@ void EngineDebugger::initialize(const String &p_uri, bool p_skip_breakpoints, co for (int i = 0; i < p_breakpoints.size(); i++) { const String &bp = p_breakpoints[i]; - int sp = bp.rfind(":"); + int sp = bp.rfind_char(':'); ERR_CONTINUE_MSG(sp == -1, vformat("Invalid breakpoint: '%s', expected file:line format.", bp)); singleton_script_debugger->insert_breakpoint(bp.substr(sp + 1, bp.length()).to_int(), bp.substr(0, sp)); diff --git a/core/debugger/local_debugger.cpp b/core/debugger/local_debugger.cpp index 5e79a6d3952..a5d807f66be 100644 --- a/core/debugger/local_debugger.cpp +++ b/core/debugger/local_debugger.cpp @@ -171,7 +171,7 @@ void LocalDebugger::debug(bool p_can_continue, bool p_is_error_breakpoint) { } else { String key_value = line.get_slicec(' ', 1); - int value_pos = key_value.find("="); + int value_pos = key_value.find_char('='); if (value_pos < 0) { print_line("Error: Invalid set format. Use: set key=value"); @@ -344,7 +344,7 @@ Pair LocalDebugger::to_breakpoint(const String &p_line) { String breakpoint_part = p_line.get_slicec(' ', 1); Pair breakpoint; - int last_colon = breakpoint_part.rfind(":"); + int last_colon = breakpoint_part.rfind_char(':'); if (last_colon < 0) { print_line("Error: Invalid breakpoint format. Expected [source:line]"); return breakpoint; diff --git a/core/debugger/remote_debugger.cpp b/core/debugger/remote_debugger.cpp index a02354b3777..f8e42e6d92b 100644 --- a/core/debugger/remote_debugger.cpp +++ b/core/debugger/remote_debugger.cpp @@ -338,7 +338,7 @@ void RemoteDebugger::_send_stack_vars(List &p_names, List &p_va } Error RemoteDebugger::_try_capture(const String &p_msg, const Array &p_data, bool &r_captured) { - const int idx = p_msg.find(":"); + const int idx = p_msg.find_char(':'); r_captured = false; if (idx < 0) { // No prefix, unknown message. return OK; @@ -610,7 +610,7 @@ void RemoteDebugger::poll_events(bool p_is_idle) { ERR_CONTINUE(arr[1].get_type() != Variant::ARRAY); const String cmd = arr[0]; - const int idx = cmd.find(":"); + const int idx = cmd.find_char(':'); bool parsed = false; if (idx < 0) { // Not prefix, use scripts capture. capture_parse("core", cmd, arr[1], parsed); diff --git a/core/debugger/remote_debugger_peer.cpp b/core/debugger/remote_debugger_peer.cpp index 793db7330fd..d38fbc8d911 100644 --- a/core/debugger/remote_debugger_peer.cpp +++ b/core/debugger/remote_debugger_peer.cpp @@ -224,7 +224,7 @@ RemoteDebuggerPeer *RemoteDebuggerPeerTCP::create(const String &p_uri) { uint16_t debug_port = 6007; if (debug_host.contains(":")) { - int sep_pos = debug_host.rfind(":"); + int sep_pos = debug_host.rfind_char(':'); debug_port = debug_host.substr(sep_pos + 1).to_int(); debug_host = debug_host.substr(0, sep_pos); } diff --git a/core/input/input.cpp b/core/input/input.cpp index 7e2227c729f..a0c00d7716d 100644 --- a/core/input/input.cpp +++ b/core/input/input.cpp @@ -236,7 +236,7 @@ void Input::get_argument_options(const StringName &p_function, int p_idx, Listpush_back(name.quote()); } } diff --git a/core/input/input_map.cpp b/core/input/input_map.cpp index 954df36f3e3..54f20a0bcce 100644 --- a/core/input/input_map.cpp +++ b/core/input/input_map.cpp @@ -104,7 +104,7 @@ void InputMap::get_argument_options(const StringName &p_function, int p_idx, Lis continue; } - String name = pi.name.substr(pi.name.find("/") + 1, pi.name.length()); + String name = pi.name.substr(pi.name.find_char('/') + 1, pi.name.length()); r_options->push_back(name.quote()); } } @@ -302,7 +302,7 @@ void InputMap::load_from_project_settings() { continue; } - String name = pi.name.substr(pi.name.find("/") + 1, pi.name.length()); + String name = pi.name.substr(pi.name.find_char('/') + 1, pi.name.length()); Dictionary action = GLOBAL_GET(pi.name); float deadzone = action.has("deadzone") ? (float)action["deadzone"] : DEFAULT_DEADZONE; diff --git a/core/io/dir_access.cpp b/core/io/dir_access.cpp index 5d2f65ca998..14588923cb3 100644 --- a/core/io/dir_access.cpp +++ b/core/io/dir_access.cpp @@ -155,9 +155,9 @@ Error DirAccess::make_dir_recursive(const String &p_dir) { } else if (full_dir.begins_with("user://")) { base = "user://"; } else if (full_dir.is_network_share_path()) { - int pos = full_dir.find("/", 2); + int pos = full_dir.find_char('/', 2); ERR_FAIL_COND_V(pos < 0, ERR_INVALID_PARAMETER); - pos = full_dir.find("/", pos + 1); + pos = full_dir.find_char('/', pos + 1); ERR_FAIL_COND_V(pos < 0, ERR_INVALID_PARAMETER); base = full_dir.substr(0, pos + 1); } else if (full_dir.begins_with("/")) { diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 9e426c49080..b7a324e710e 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -101,7 +101,7 @@ Error HTTPClient::verify_headers(const Vector &p_headers) { for (int i = 0; i < p_headers.size(); i++) { String sanitized = p_headers[i].strip_edges(); ERR_FAIL_COND_V_MSG(sanitized.is_empty(), ERR_INVALID_PARAMETER, vformat("Invalid HTTP header at index %d: empty.", i)); - ERR_FAIL_COND_V_MSG(sanitized.find(":") < 1, ERR_INVALID_PARAMETER, + ERR_FAIL_COND_V_MSG(sanitized.find_char(':') < 1, ERR_INVALID_PARAMETER, vformat("Invalid HTTP header at index %d: String must contain header-value pair, delimited by ':', but was: '%s'.", i, p_headers[i])); } @@ -113,7 +113,7 @@ Dictionary HTTPClient::_get_response_headers_as_dictionary() { get_response_headers(&rh); Dictionary ret; for (const String &s : rh) { - int sp = s.find(":"); + int sp = s.find_char(':'); if (sp == -1) { continue; } diff --git a/core/io/http_client_tcp.cpp b/core/io/http_client_tcp.cpp index 237ba30a806..1382aecb38d 100644 --- a/core/io/http_client_tcp.cpp +++ b/core/io/http_client_tcp.cpp @@ -508,11 +508,11 @@ Error HTTPClientTCP::poll() { continue; } if (s.begins_with("content-length:")) { - body_size = s.substr(s.find(":") + 1, s.length()).strip_edges().to_int(); + body_size = s.substr(s.find_char(':') + 1, s.length()).strip_edges().to_int(); body_left = body_size; } else if (s.begins_with("transfer-encoding:")) { - String encoding = header.substr(header.find(":") + 1, header.length()).strip_edges(); + String encoding = header.substr(header.find_char(':') + 1, header.length()).strip_edges(); if (encoding == "chunked") { chunked = true; } diff --git a/core/io/plist.cpp b/core/io/plist.cpp index 32e83c31f2d..26b8c39495a 100644 --- a/core/io/plist.cpp +++ b/core/io/plist.cpp @@ -661,12 +661,12 @@ bool PList::load_string(const String &p_string, String &r_err_out) { List> stack; String key; while (pos >= 0) { - int open_token_s = p_string.find("<", pos); + int open_token_s = p_string.find_char('<', pos); if (open_token_s == -1) { r_err_out = "Unexpected end of data. No tags found."; return false; } - int open_token_e = p_string.find(">", open_token_s); + int open_token_e = p_string.find_char('>', open_token_s); pos = open_token_e; String token = p_string.substr(open_token_s + 1, open_token_e - open_token_s - 1); @@ -676,7 +676,7 @@ bool PList::load_string(const String &p_string, String &r_err_out) { } String value; if (token[0] == '?' || token[0] == '!') { // Skip and - int end_token_e = p_string.find(">", open_token_s); + int end_token_e = p_string.find_char('>', open_token_s); pos = end_token_e; continue; } @@ -769,7 +769,7 @@ bool PList::load_string(const String &p_string, String &r_err_out) { r_err_out = vformat("Mismatched <%s> tag.", token); return false; } - int end_token_e = p_string.find(">", end_token_s); + int end_token_e = p_string.find_char('>', end_token_s); pos = end_token_e; String end_token = p_string.substr(end_token_s + 2, end_token_e - end_token_s - 2); if (end_token != token) { diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index 3fea697d0b5..ecd0a91aa4c 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -1206,7 +1206,7 @@ String ResourceLoader::_path_remap(const String &p_path, bool *r_translation_rem int best_score = 0; for (int i = 0; i < res_remaps.size(); i++) { - int split = res_remaps[i].rfind(":"); + int split = res_remaps[i].rfind_char(':'); if (split == -1) { continue; } @@ -1498,11 +1498,11 @@ Vector ResourceLoader::list_directory(const String &p_directory) { } } else { if (d.ends_with(".import") || d.ends_with(".remap") || d.ends_with(".uid")) { - d = d.substr(0, d.rfind(".")); + d = d.substr(0, d.rfind_char('.')); } if (d.ends_with(".gdc")) { - d = d.substr(0, d.rfind(".")); + d = d.substr(0, d.rfind_char('.')); d += ".gd"; } diff --git a/core/io/translation_loader_po.cpp b/core/io/translation_loader_po.cpp index 7a11d06df6d..1761d6fa234 100644 --- a/core/io/translation_loader_po.cpp +++ b/core/io/translation_loader_po.cpp @@ -108,7 +108,7 @@ Ref TranslationLoaderPO::load_translation(Ref f, Error *r_ // Record plural rule. int p_start = config.find("Plural-Forms"); if (p_start != -1) { - int p_end = config.find("\n", p_start); + int p_end = config.find_char('\n', p_start); translation->set_plural_rule(config.substr(p_start, p_end - p_start)); } } else { @@ -224,7 +224,7 @@ Ref TranslationLoaderPO::load_translation(Ref f, Error *r_ // Record plural rule. int p_start = config.find("Plural-Forms"); if (p_start != -1) { - int p_end = config.find("\n", p_start); + int p_end = config.find_char('\n', p_start); translation->set_plural_rule(config.substr(p_start, p_end - p_start)); plural_forms = translation->get_plural_forms(); } @@ -324,7 +324,7 @@ Ref TranslationLoaderPO::load_translation(Ref f, Error *r_ Vector configs = config.split("\n"); for (int i = 0; i < configs.size(); i++) { String c = configs[i].strip_edges(); - int p = c.find(":"); + int p = c.find_char(':'); if (p == -1) { continue; } diff --git a/core/string/node_path.cpp b/core/string/node_path.cpp index 3faf3bb0c50..40c81edf4ce 100644 --- a/core/string/node_path.cpp +++ b/core/string/node_path.cpp @@ -407,7 +407,7 @@ NodePath::NodePath(const String &p_path) { bool absolute = (path[0] == '/'); bool last_is_slash = true; int slices = 0; - int subpath_pos = path.find(":"); + int subpath_pos = path.find_char(':'); if (subpath_pos != -1) { int from = subpath_pos + 1; diff --git a/core/string/translation_po.cpp b/core/string/translation_po.cpp index da79e472e73..7eb8a2afeba 100644 --- a/core/string/translation_po.cpp +++ b/core/string/translation_po.cpp @@ -227,11 +227,11 @@ void TranslationPO::set_plural_rule(const String &p_plural_rule) { // Set plural_forms and plural_rule. // p_plural_rule passed in has the form "Plural-Forms: nplurals=2; plural=(n >= 2);". - int first_semi_col = p_plural_rule.find(";"); - plural_forms = p_plural_rule.substr(p_plural_rule.find("=") + 1, first_semi_col - (p_plural_rule.find("=") + 1)).to_int(); + int first_semi_col = p_plural_rule.find_char(';'); + plural_forms = p_plural_rule.substr(p_plural_rule.find_char('=') + 1, first_semi_col - (p_plural_rule.find_char('=') + 1)).to_int(); - int expression_start = p_plural_rule.find("=", first_semi_col) + 1; - int second_semi_col = p_plural_rule.rfind(";"); + int expression_start = p_plural_rule.find_char('=', first_semi_col) + 1; + int second_semi_col = p_plural_rule.rfind_char(';'); plural_rule = p_plural_rule.substr(expression_start, second_semi_col - expression_start).strip_edges(); // Setup the cache to make evaluating plural rule faster later on. diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index 521dfe0b8ca..9e99fc3b2f5 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -246,27 +246,27 @@ Error String::parse_url(String &r_scheme, String &r_host, int &r_port, String &r base = base.substr(pos + 3, base.length() - pos - 3); } } - pos = base.find("#"); + pos = base.find_char('#'); // Fragment if (pos != -1) { r_fragment = base.substr(pos + 1); base = base.substr(0, pos); } - pos = base.find("/"); + pos = base.find_char('/'); // Path if (pos != -1) { r_path = base.substr(pos, base.length() - pos); base = base.substr(0, pos); } // Host - pos = base.find("@"); + pos = base.find_char('@'); if (pos != -1) { // Strip credentials base = base.substr(pos + 1, base.length() - pos - 1); } if (base.begins_with("[")) { // Literal IPv6 - pos = base.rfind("]"); + pos = base.rfind_char(']'); if (pos == -1) { return ERR_INVALID_PARAMETER; } @@ -277,7 +277,7 @@ Error String::parse_url(String &r_scheme, String &r_host, int &r_port, String &r if (base.get_slice_count(":") > 2) { return ERR_INVALID_PARAMETER; } - pos = base.rfind(":"); + pos = base.rfind_char(':'); if (pos == -1) { r_host = base; base = ""; @@ -2641,7 +2641,7 @@ int64_t String::to_int() const { return 0; } - int to = (find(".") >= 0) ? find(".") : length(); + int to = (find_char('.') >= 0) ? find_char('.') : length(); int64_t integer = 0; int64_t sign = 1; @@ -4580,7 +4580,7 @@ String String::simplify_path() const { if (p == -1) { p = s.find(":\\"); } - if (p != -1 && p < s.find("/")) { + if (p != -1 && p < s.find_char('/')) { drive = s.substr(0, p + 2); s = s.substr(p + 2); } @@ -5025,7 +5025,7 @@ String String::xml_unescape() const { String String::pad_decimals(int p_digits) const { String s = *this; - int c = s.find("."); + int c = s.find_char('.'); if (c == -1) { if (p_digits <= 0) { @@ -5049,7 +5049,7 @@ String String::pad_decimals(int p_digits) const { String String::pad_zeros(int p_digits) const { String s = *this; - int end = s.find("."); + int end = s.find_char('.'); if (end == -1) { end = s.length(); @@ -5316,7 +5316,7 @@ String String::validate_filename() const { } bool String::is_valid_ip_address() const { - if (find(":") >= 0) { + if (find_char(':') >= 0) { Vector ip = split(":"); for (int i = 0; i < ip.size(); i++) { const String &n = ip[i]; @@ -5386,13 +5386,13 @@ String String::get_base_dir() const { // Windows UNC network share path. if (end == 0) { if (is_network_share_path()) { - basepos = find("/", 2); + basepos = find_char('/', 2); if (basepos == -1) { - basepos = find("\\", 2); + basepos = find_char('\\', 2); } - int servpos = find("/", basepos + 1); + int servpos = find_char('/', basepos + 1); if (servpos == -1) { - servpos = find("\\", basepos + 1); + servpos = find_char('\\', basepos + 1); } if (servpos != -1) { end = servpos + 1; @@ -5416,7 +5416,7 @@ String String::get_base_dir() const { rs = *this; } - int sep = MAX(rs.rfind("/"), rs.rfind("\\")); + int sep = MAX(rs.rfind_char('/'), rs.rfind_char('\\')); if (sep == -1) { return base; } @@ -5425,7 +5425,7 @@ String String::get_base_dir() const { } String String::get_file() const { - int sep = MAX(rfind("/"), rfind("\\")); + int sep = MAX(rfind_char('/'), rfind_char('\\')); if (sep == -1) { return *this; } @@ -5434,8 +5434,8 @@ String String::get_file() const { } String String::get_extension() const { - int pos = rfind("."); - if (pos < 0 || pos < MAX(rfind("/"), rfind("\\"))) { + int pos = rfind_char('.'); + if (pos < 0 || pos < MAX(rfind_char('/'), rfind_char('\\'))) { return ""; } @@ -5533,8 +5533,8 @@ String String::validate_node_name() const { } String String::get_basename() const { - int pos = rfind("."); - if (pos < 0 || pos < MAX(rfind("/"), rfind("\\"))) { + int pos = rfind_char('.'); + if (pos < 0 || pos < MAX(rfind_char('/'), rfind_char('\\'))) { return *this; } diff --git a/drivers/alsa/audio_driver_alsa.cpp b/drivers/alsa/audio_driver_alsa.cpp index 0c9635339bb..6ee22b6eb59 100644 --- a/drivers/alsa/audio_driver_alsa.cpp +++ b/drivers/alsa/audio_driver_alsa.cpp @@ -80,7 +80,7 @@ Error AudioDriverALSA::init_output_device() { status = snd_pcm_open(&pcm_handle, "default", SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK); } else { String device = output_device_name; - int pos = device.find(";"); + int pos = device.find_char(';'); if (pos != -1) { device = device.substr(0, pos); } diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 3976ae7d84d..ffc270cd36e 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -860,7 +860,7 @@ String OS_Unix::get_locale() const { } String locale = get_environment("LANG"); - int tp = locale.find("."); + int tp = locale.find_char('.'); if (tp != -1) { locale = locale.substr(0, tp); } diff --git a/drivers/windows/dir_access_windows.cpp b/drivers/windows/dir_access_windows.cpp index 24a26b56ef6..3ddbde72c40 100644 --- a/drivers/windows/dir_access_windows.cpp +++ b/drivers/windows/dir_access_windows.cpp @@ -230,7 +230,7 @@ String DirAccessWindows::get_current_dir(bool p_include_drive) const { return cdir; } else { if (_get_root_string().is_empty()) { - int pos = cdir.find(":"); + int pos = cdir.find_char(':'); if (pos != -1) { return cdir.substr(pos + 1); } @@ -344,7 +344,7 @@ String DirAccessWindows::get_filesystem_type() const { return "Network Share"; } - int unit_end = path.find(":"); + int unit_end = path.find_char(':'); ERR_FAIL_COND_V(unit_end == -1, String()); String unit = path.substr(0, unit_end + 1) + "\\"; diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp index 7d2247d41ac..4a0e5e5f499 100644 --- a/drivers/windows/file_access_windows.cpp +++ b/drivers/windows/file_access_windows.cpp @@ -64,7 +64,7 @@ bool FileAccessWindows::is_path_invalid(const String &p_path) { // Check for invalid operating system file. String fname = p_path.get_file().to_lower(); - int dot = fname.find("."); + int dot = fname.find_char('.'); if (dot != -1) { fname = fname.substr(0, dot); } diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index b923dc07322..36ca4176387 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -275,7 +275,7 @@ void AnimationBezierTrackEdit::_notification(int p_what) { } String base_path = animation->track_get_path(i); - int end = base_path.find(":"); + int end = base_path.find_char(':'); if (end != -1) { base_path = base_path.substr(0, end + 1); } diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 55ea7c0082a..7a1296c4111 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -4340,7 +4340,7 @@ void AnimationTrackEditor::insert_node_value_key(Node *p_node, const String &p_p if (track_path == np) { actual_value = value; // All good. } else { - int sep = track_path.rfind(":"); + int sep = track_path.rfind_char(':'); if (sep != -1) { String base_path = track_path.substr(0, sep); if (base_path == np) { @@ -6495,7 +6495,7 @@ void AnimationTrackEditor::_edit_menu_pressed(int p_option) { path = NodePath(node->get_path().get_names(), path.get_subnames(), true); // Store full path instead for copying. } else { text = path; - int sep = text.find(":"); + int sep = text.find_char(':'); if (sep != -1) { text = text.substr(sep + 1, text.length()); } diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index b114977c3b1..d76c324be05 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -524,7 +524,7 @@ void ConnectDialog::set_dst_node(Node *p_node) { StringName ConnectDialog::get_dst_method_name() const { String txt = dst_method->get_text(); if (txt.contains("(")) { - txt = txt.left(txt.find("(")).strip_edges(); + txt = txt.left(txt.find_char('(')).strip_edges(); } return txt; } diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 78dc772d9e9..2273014f720 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -160,13 +160,13 @@ bool CreateDialog::_should_hide_type(const StringName &p_type) const { String script_path = ScriptServer::get_global_class_path(p_type); if (script_path.begins_with("res://addons/")) { - int i = script_path.find("/", 13); // 13 is length of "res://addons/". + int i = script_path.find_char('/', 13); // 13 is length of "res://addons/". while (i > -1) { const String plugin_path = script_path.substr(0, i).path_join("plugin.cfg"); if (FileAccess::exists(plugin_path)) { return !EditorNode::get_singleton()->is_addon_plugin_enabled(plugin_path); } - i = script_path.find("/", i + 1); + i = script_path.find_char('/', i + 1); } } } diff --git a/editor/debugger/debug_adapter/debug_adapter_parser.cpp b/editor/debugger/debug_adapter/debug_adapter_parser.cpp index 2af629676ab..904085630ba 100644 --- a/editor/debugger/debug_adapter/debug_adapter_parser.cpp +++ b/editor/debugger/debug_adapter/debug_adapter_parser.cpp @@ -147,7 +147,7 @@ Dictionary DebugAdapterParser::req_initialize(const Dictionary &p_params) const for (List::Element *E = breakpoints.front(); E; E = E->next()) { String breakpoint = E->get(); - String path = breakpoint.left(breakpoint.find(":", 6)); // Skip initial part of path, aka "res://" + String path = breakpoint.left(breakpoint.find_char(':', 6)); // Skip initial part of path, aka "res://" int line = breakpoint.substr(path.size()).to_int(); DebugAdapterProtocol::get_singleton()->on_debug_breakpoint_toggled(path, line, true); diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp index 0f948b4ed59..909651da454 100644 --- a/editor/debugger/editor_debugger_node.cpp +++ b/editor/debugger/editor_debugger_node.cpp @@ -160,9 +160,9 @@ void EditorDebuggerNode::_text_editor_stack_goto(const ScriptEditorDebugger *p_d } else { // If the script is built-in, it can be opened only if the scene is loaded in memory. int i = file.find("::"); - int j = file.rfind("(", i); + int j = file.rfind_char('(', i); if (j > -1) { // If the script is named, the string is "name (file)", so we need to extract the path. - file = file.substr(j + 1, file.find(")", i) - j - 1); + file = file.substr(j + 1, file.find_char(')', i) - j - 1); } Ref ps = ResourceLoader::load(file.get_slice("::", 0)); stack_script = ResourceLoader::load(file); @@ -183,9 +183,9 @@ void EditorDebuggerNode::_text_editor_stack_clear(const ScriptEditorDebugger *p_ } else { // If the script is built-in, it can be opened only if the scene is loaded in memory. int i = file.find("::"); - int j = file.rfind("(", i); + int j = file.rfind_char('(', i); if (j > -1) { // If the script is named, the string is "name (file)", so we need to extract the path. - file = file.substr(j + 1, file.find(")", i) - j - 1); + file = file.substr(j + 1, file.find_char(')', i) - j - 1); } Ref ps = ResourceLoader::load(file.get_slice("::", 0)); stack_script = ResourceLoader::load(file); diff --git a/editor/debugger/editor_debugger_tree.cpp b/editor/debugger/editor_debugger_tree.cpp index 4d67800e6ec..a9e4adf674c 100644 --- a/editor/debugger/editor_debugger_tree.cpp +++ b/editor/debugger/editor_debugger_tree.cpp @@ -382,7 +382,7 @@ void EditorDebuggerTree::_item_menu_id_pressed(int p_option) { text = "."; } else { text = text.replace("/root/", ""); - int slash = text.find("/"); + int slash = text.find_char('/'); if (slash < 0) { text = "."; } else { diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp index 8ba5811ffa6..9ca12070fec 100644 --- a/editor/dependency_editor.cpp +++ b/editor/dependency_editor.cpp @@ -471,7 +471,7 @@ void DependencyRemoveDialog::_find_localization_remaps_of_removed_files(Vectorupdate(); if (p_mode == MODE_FILE) { - int extension_pos = p_default_name.rfind("."); + int extension_pos = p_default_name.rfind_char('.'); if (extension_pos > -1) { dir_path->select(0, extension_pos); return; diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp index bce0c874529..72755e8943d 100644 --- a/editor/editor_asset_installer.cpp +++ b/editor/editor_asset_installer.cpp @@ -130,14 +130,14 @@ void EditorAssetInstaller::open_asset(const String &p_path, bool p_autoskip_topl // Create intermediate directories if they aren't reported by unzip. // We are only interested in subfolders, so skip the root slash. - int separator = source_name.find("/", 1); + int separator = source_name.find_char('/', 1); while (separator != -1) { String dir_name = source_name.substr(0, separator + 1); if (!dir_name.is_empty() && !asset_files.has(dir_name)) { asset_files.insert(dir_name); } - separator = source_name.find("/", separator + 1); + separator = source_name.find_char('/', separator + 1); } if (!source_name.is_empty() && !asset_files.has(source_name)) { @@ -214,7 +214,7 @@ void EditorAssetInstaller::_rebuild_source_tree() { TreeItem *parent_item; - int separator = path.rfind("/"); + int separator = path.rfind_char('/'); if (separator == -1) { parent_item = root; } else { @@ -313,7 +313,7 @@ void EditorAssetInstaller::_rebuild_destination_tree() { TreeItem *parent_item; - int separator = path.rfind("/"); + int separator = path.rfind_char('/'); if (separator == -1) { parent_item = root; } else { diff --git a/editor/editor_folding.cpp b/editor/editor_folding.cpp index 18f56106552..5cb38fa8751 100644 --- a/editor/editor_folding.cpp +++ b/editor/editor_folding.cpp @@ -249,7 +249,7 @@ void EditorFolding::_do_object_unfolds(Object *p_object, HashSet> } } } else { //path - int last = E.name.rfind("/"); + int last = E.name.rfind_char('/'); if (last != -1) { bool can_revert = EditorPropertyRevert::can_property_revert(p_object, E.name); if (can_revert) { diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 0ca1ed2d50e..9aec9d6b155 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -148,7 +148,7 @@ static String _contextualize_class_specifier(const String &p_class_specifier, co // Here equal length + begins_with from above implies p_class_specifier == p_edited_class :) if (p_class_specifier.length() == p_edited_class.length()) { - int rfind = p_class_specifier.rfind("."); + int rfind = p_class_specifier.rfind_char('.'); if (rfind == -1) { // Single identifier return p_class_specifier; } @@ -234,7 +234,7 @@ void EditorHelp::_class_desc_select(const String &p_select) { enum_class_name = "@GlobalScope"; enum_name = link; } else { - const int dot_pos = link.rfind("."); + const int dot_pos = link.rfind_char('.'); if (dot_pos >= 0) { enum_class_name = link.left(dot_pos); enum_name = link.substr(dot_pos + 1); @@ -3252,7 +3252,7 @@ EditorHelpBit::HelpData EditorHelpBit::_get_property_help_data(const StringName enum_class_name = "@GlobalScope"; enum_name = property.enumeration; } else { - const int dot_pos = property.enumeration.rfind("."); + const int dot_pos = property.enumeration.rfind_char('.'); if (dot_pos >= 0) { enum_class_name = property.enumeration.left(dot_pos); enum_name = property.enumeration.substr(dot_pos + 1); @@ -3619,7 +3619,7 @@ void EditorHelpBit::_meta_clicked(const String &p_select) { enum_class_name = "@GlobalScope"; enum_name = link; } else { - const int dot_pos = link.rfind("."); + const int dot_pos = link.rfind_char('.'); if (dot_pos >= 0) { enum_class_name = link.left(dot_pos); enum_name = link.substr(dot_pos + 1); diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index fa5a059aa0b..6b3c6b462d1 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -3131,7 +3131,7 @@ void EditorInspector::update_tree() { if (!array_prefix.is_empty()) { path = path.trim_prefix(array_prefix); - int char_index = path.find("/"); + int char_index = path.find_char('/'); if (char_index >= 0) { path = path.right(-char_index - 1); } else { @@ -3171,10 +3171,10 @@ void EditorInspector::update_tree() { } // Get the property label's string. - String name_override = (path.contains("/")) ? path.substr(path.rfind("/") + 1) : path; + String name_override = (path.contains("/")) ? path.substr(path.rfind_char('/') + 1) : path; String feature_tag; { - const int dot = name_override.find("."); + const int dot = name_override.find_char('.'); if (dot != -1) { feature_tag = name_override.substr(dot); name_override = name_override.substr(0, dot); @@ -3189,7 +3189,7 @@ void EditorInspector::update_tree() { const String property_label_string = EditorPropertyNameProcessor::get_singleton()->process_name(name_override, name_style, p.name, doc_name) + feature_tag; // Remove the property from the path. - int idx = path.rfind("/"); + int idx = path.rfind_char('/'); if (idx > -1) { path = path.left(idx); } else { @@ -3320,7 +3320,7 @@ void EditorInspector::update_tree() { array_element_prefix = class_name_components[0]; editor_inspector_array = memnew(EditorInspectorArray(all_read_only)); - String array_label = path.contains("/") ? path.substr(path.rfind("/") + 1) : path; + String array_label = path.contains("/") ? path.substr(path.rfind_char('/') + 1) : path; array_label = EditorPropertyNameProcessor::get_singleton()->process_name(property_label_string, property_name_style, p.name, doc_name); int page = per_array_page.has(array_element_prefix) ? per_array_page[array_element_prefix] : 0; editor_inspector_array->setup_with_move_element_function(object, array_label, array_element_prefix, page, c, use_folding); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 87f1f1b8a02..f056a477c41 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -253,8 +253,8 @@ void EditorNode::disambiguate_filenames(const Vector p_full_paths, Vecto // append that to yield "folder/foo.tscn". if (difference > 0) { String parent = full_path.substr(0, difference); - int slash_idx = parent.rfind("/"); - slash_idx = parent.rfind("/", slash_idx - 1); + int slash_idx = parent.rfind_char('/'); + slash_idx = parent.rfind_char('/', slash_idx - 1); parent = (slash_idx >= 0 && parent.length() > 1) ? parent.substr(slash_idx + 1) : parent; r_filenames.write[set_idx] = parent + r_filenames[set_idx]; } diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index 4b4c02f49bf..3cc3a0f7c2a 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -740,10 +740,10 @@ void EditorPropertyArray::setup(Variant::Type p_array_type, const String &p_hint // The format of p_hint_string is: // subType/subTypeHint:nextSubtype ... etc. if (!p_hint_string.is_empty()) { - int hint_subtype_separator = p_hint_string.find(":"); + int hint_subtype_separator = p_hint_string.find_char(':'); if (hint_subtype_separator >= 0) { String subtype_string = p_hint_string.substr(0, hint_subtype_separator); - int slash_pos = subtype_string.find("/"); + int slash_pos = subtype_string.find_char('/'); if (slash_pos >= 0) { subtype_hint = PropertyHint(subtype_string.substr(slash_pos + 1, subtype_string.size() - slash_pos - 1).to_int()); subtype_string = subtype_string.substr(0, slash_pos); @@ -1006,10 +1006,10 @@ void EditorPropertyDictionary::setup(PropertyHint p_hint, const String &p_hint_s PackedStringArray types = p_hint_string.split(";"); if (types.size() > 0 && !types[0].is_empty()) { String key = types[0]; - int hint_key_subtype_separator = key.find(":"); + int hint_key_subtype_separator = key.find_char(':'); if (hint_key_subtype_separator >= 0) { String key_subtype_string = key.substr(0, hint_key_subtype_separator); - int slash_pos = key_subtype_string.find("/"); + int slash_pos = key_subtype_string.find_char('/'); if (slash_pos >= 0) { key_subtype_hint = PropertyHint(key_subtype_string.substr(slash_pos + 1, key_subtype_string.size() - slash_pos - 1).to_int()); key_subtype_string = key_subtype_string.substr(0, slash_pos); @@ -1025,10 +1025,10 @@ void EditorPropertyDictionary::setup(PropertyHint p_hint, const String &p_hint_s } if (types.size() > 1 && !types[1].is_empty()) { String value = types[1]; - int hint_value_subtype_separator = value.find(":"); + int hint_value_subtype_separator = value.find_char(':'); if (hint_value_subtype_separator >= 0) { String value_subtype_string = value.substr(0, hint_value_subtype_separator); - int slash_pos = value_subtype_string.find("/"); + int slash_pos = value_subtype_string.find_char('/'); if (slash_pos >= 0) { value_subtype_hint = PropertyHint(value_subtype_string.substr(slash_pos + 1, value_subtype_string.size() - slash_pos - 1).to_int()); value_subtype_string = value_subtype_string.substr(0, slash_pos); diff --git a/editor/editor_sectioned_inspector.cpp b/editor/editor_sectioned_inspector.cpp index 27cbb9810c7..d88cc4d5fa7 100644 --- a/editor/editor_sectioned_inspector.cpp +++ b/editor/editor_sectioned_inspector.cpp @@ -96,7 +96,7 @@ class SectionedInspectorFilter : public Object { List pinfo; edited->get_property_list(&pinfo); for (PropertyInfo &pi : pinfo) { - int sp = pi.name.find("/"); + int sp = pi.name.find_char('/'); if (pi.name == "resource_path" || pi.name == "resource_name" || pi.name == "resource_local_to_scene" || pi.name.begins_with("script/") || pi.name.begins_with("_global_script")) { //skip resource stuff continue; @@ -255,7 +255,7 @@ void SectionedInspector::update_category_list() { continue; } - int sp = pi.name.find("/"); + int sp = pi.name.find_char('/'); if (sp == -1) { pi.name = "global/" + pi.name; } diff --git a/editor/engine_update_label.cpp b/editor/engine_update_label.cpp index facbfc7c6ba..0d401812572 100644 --- a/editor/engine_update_label.cpp +++ b/editor/engine_update_label.cpp @@ -240,8 +240,8 @@ EngineUpdateLabel::VersionType EngineUpdateLabel::_get_version_type(const String } String EngineUpdateLabel::_extract_sub_string(const String &p_line) const { - int j = p_line.find("\"") + 1; - return p_line.substr(j, p_line.find("\"", j) - j); + int j = p_line.find_char('"') + 1; + return p_line.substr(j, p_line.find_char('"', j) - j); } void EngineUpdateLabel::_notification(int p_what) { diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 3921cde71ef..c7e12d1f3b5 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -137,7 +137,7 @@ bool FileSystemList::edit_selected() { String name = get_item_text(s); line_editor->set_text(name); - line_editor->select(0, name.rfind(".")); + line_editor->select(0, name.rfind_char('.')); popup_edit_commited = false; // Start edit popup processing. popup_editor->popup(); @@ -2432,7 +2432,7 @@ void FileSystemDock::_file_option(int p_option, const Vector &p_selected if (to_rename.is_file) { String name = to_rename.path.get_file(); - tree->set_editor_selection(0, name.rfind(".")); + tree->set_editor_selection(0, name.rfind_char('.')); } else { String name = to_rename.path.left(-1).get_file(); // Removes the "/" suffix for folders. tree->set_editor_selection(0, name.length()); @@ -3658,10 +3658,10 @@ void FileSystemDock::_file_list_gui_input(Ref p_event) { tree_item->select(0); } else { // Find parent folder. - fpath = fpath.substr(0, fpath.rfind("/") + 1); + fpath = fpath.substr(0, fpath.rfind_char('/') + 1); if (fpath.size() > String("res://").size()) { fpath = fpath.left(fpath.size() - 2); // Remove last '/'. - const int slash_idx = fpath.rfind("/"); + const int slash_idx = fpath.rfind_char('/'); fpath = fpath.substr(slash_idx + 1, fpath.size() - slash_idx - 1); } diff --git a/editor/gui/editor_file_dialog.cpp b/editor/gui/editor_file_dialog.cpp index 12f00b7a57f..03816098047 100644 --- a/editor/gui/editor_file_dialog.cpp +++ b/editor/gui/editor_file_dialog.cpp @@ -156,7 +156,7 @@ void EditorFileDialog::popup_file_dialog() { } void EditorFileDialog::_focus_file_text() { - int lp = file->get_text().rfind("."); + int lp = file->get_text().rfind_char('.'); if (lp != -1) { file->select(0, lp); file->grab_focus(); @@ -1263,7 +1263,7 @@ void EditorFileDialog::set_current_path(const String &p_path) { if (!p_path.size()) { return; } - int pos = MAX(p_path.rfind("/"), p_path.rfind("\\")); + int pos = MAX(p_path.rfind_char('/'), p_path.rfind_char('\\')); if (pos == -1) { set_current_file(p_path); } else { diff --git a/editor/import/resource_importer_imagefont.cpp b/editor/import/resource_importer_imagefont.cpp index 44ae2b5ff1c..950058e88ef 100644 --- a/editor/import/resource_importer_imagefont.cpp +++ b/editor/import/resource_importer_imagefont.cpp @@ -199,7 +199,7 @@ Error ResourceImporterImageFont::import(ResourceUID::ID p_source_id, const Strin case STEP_OFF_Y_BEGIN: { // Read advance and offset. if (range[c] == ' ') { - int next = range.find(" ", c + 1); + int next = range.find_char(' ', c + 1); if (next < c) { next = range.length(); } diff --git a/editor/localization_editor.cpp b/editor/localization_editor.cpp index 921467ccbc3..7b2e6e81ee2 100644 --- a/editor/localization_editor.cpp +++ b/editor/localization_editor.cpp @@ -441,7 +441,7 @@ void LocalizationEditor::_filesystem_files_moved(const String &p_old_file, const bool remapped_files_updated = false; for (int j = 0; j < remapped_files.size(); j++) { - int splitter_pos = remapped_files[j].rfind(":"); + int splitter_pos = remapped_files[j].rfind_char(':'); String res_path = remapped_files[j].substr(0, splitter_pos); if (res_path == p_old_file) { @@ -482,7 +482,7 @@ void LocalizationEditor::_filesystem_file_removed(const String &p_file) { for (int i = 0; i < remap_keys.size() && !remaps_changed; i++) { PackedStringArray remapped_files = remaps[remap_keys[i]]; for (int j = 0; j < remapped_files.size() && !remaps_changed; j++) { - int splitter_pos = remapped_files[j].rfind(":"); + int splitter_pos = remapped_files[j].rfind_char(':'); String res_path = remapped_files[j].substr(0, splitter_pos); remaps_changed = p_file == res_path; if (remaps_changed) { @@ -567,7 +567,7 @@ void LocalizationEditor::update_translations() { PackedStringArray selected = remaps[keys[i]]; for (int j = 0; j < selected.size(); j++) { const String &s2 = selected[j]; - int qp = s2.rfind(":"); + int qp = s2.rfind_char(':'); String path = s2.substr(0, qp); String locale = s2.substr(qp + 1, s2.length()); diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index 8db106da074..7c9c003ea1f 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -907,7 +907,7 @@ void EditorAssetLibrary::_image_request_completed(int p_status, int p_code, cons for (int i = 0; i < headers.size(); i++) { if (headers[i].findn("ETag:") == 0) { // Save etag String cache_filename_base = EditorPaths::get_singleton()->get_cache_dir().path_join("assetimage_" + image_queue[p_queue_id].image_url.md5_text()); - String new_etag = headers[i].substr(headers[i].find(":") + 1, headers[i].length()).strip_edges(); + String new_etag = headers[i].substr(headers[i].find_char(':') + 1, headers[i].length()).strip_edges(); Ref file = FileAccess::open(cache_filename_base + ".etag", FileAccess::WRITE); if (file.is_valid()) { file->store_line(new_etag); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index fc8b8aa49f5..cf586c792ea 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -282,7 +282,7 @@ void ScriptTextEditor::_warning_clicked(const Variant &p_line) { CodeEdit *text_editor = code_editor->get_text_editor(); String prev_line = line > 0 ? text_editor->get_line(line - 1) : ""; if (prev_line.contains("@warning_ignore")) { - const int closing_bracket_idx = prev_line.find(")"); + const int closing_bracket_idx = prev_line.find_char(')'); const String text_to_insert = ", " + code.quote(quote_style); text_editor->insert_text(text_to_insert, line - 1, closing_bracket_idx); } else { @@ -1205,7 +1205,7 @@ void ScriptTextEditor::_update_connected_methods() { // Account for inner classes by stripping the class names from the method, // starting from the right since our inner class might be inside of another inner class. - int pos = raw_name.rfind("."); + int pos = raw_name.rfind_char('.'); if (pos != -1) { name = raw_name.substr(pos + 1); } diff --git a/editor/project_converter_3_to_4.cpp b/editor/project_converter_3_to_4.cpp index d08610c93fc..edf3ff72961 100644 --- a/editor/project_converter_3_to_4.cpp +++ b/editor/project_converter_3_to_4.cpp @@ -1970,7 +1970,7 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai // -- func c(var a, var b) -> func c(a, b) if (line.contains("func ") && line.contains("var ")) { int start = line.find("func "); - start = line.substr(start).find("(") + start; + start = line.substr(start).find_char('(') + start; int end = get_end_parenthesis(line.substr(start)) + 1; if (end > -1) { Vector parts = parse_arguments(line.substr(start, end)); @@ -2120,12 +2120,12 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai } } // -- func _init(p_x:int).(p_x): -> func _init(p_x:int):\n\tsuper(p_x) Object # https://github.com/godotengine/godot/issues/70542 - if (line.contains(" _init(") && line.rfind(":") > 0) { + if (line.contains(" _init(") && line.rfind_char(':') > 0) { // func _init(p_arg1).(super4, super5, super6)->void: // ^--^indent ^super_start super_end^ int indent = line.count("\t", 0, line.find("func")); int super_start = line.find(".("); - int super_end = line.rfind(")"); + int super_end = line.rfind_char(')'); if (super_start > 0 && super_end > super_start) { line = line.substr(0, super_start) + line.substr(super_end + 1) + "\n" + String("\t").repeat(indent + 1) + "super" + line.substr(super_start + 1, super_end - super_start); } diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index d38ff7af764..8615836ddda 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -144,7 +144,7 @@ void ScriptCreateDialog::_notification(int p_what) { void ScriptCreateDialog::_path_hbox_sorted() { if (is_visible()) { - int filename_start_pos = file_path->get_text().rfind("/") + 1; + int filename_start_pos = file_path->get_text().rfind_char('/') + 1; int filename_end_pos = file_path->get_text().get_basename().length(); if (!is_built_in) { diff --git a/editor/shader_create_dialog.cpp b/editor/shader_create_dialog.cpp index e1c797633ac..33da3dd10c7 100644 --- a/editor/shader_create_dialog.cpp +++ b/editor/shader_create_dialog.cpp @@ -103,7 +103,7 @@ void ShaderCreateDialog::_update_language_info() { void ShaderCreateDialog::_path_hbox_sorted() { if (is_visible()) { - int filename_start_pos = initial_base_path.rfind("/") + 1; + int filename_start_pos = initial_base_path.rfind_char('/') + 1; int filename_end_pos = initial_base_path.length(); if (!is_built_in) { diff --git a/main/main.cpp b/main/main.cpp index 2c41acef8bc..340167fe00d 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1598,7 +1598,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph } else if (arg.ends_with("project.godot")) { String path; String file = arg; - int sep = MAX(file.rfind("/"), file.rfind("\\")); + int sep = MAX(file.rfind_char('/'), file.rfind_char('\\')); if (sep == -1) { path = "."; } else { @@ -4145,7 +4145,7 @@ int Main::start() { local_game_path = "res://" + local_game_path; } else { - int sep = local_game_path.rfind("/"); + int sep = local_game_path.rfind_char('/'); if (sep == -1) { Ref da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); diff --git a/modules/gdscript/editor/gdscript_docgen.cpp b/modules/gdscript/editor/gdscript_docgen.cpp index 758887a7236..3a5a88d3567 100644 --- a/modules/gdscript/editor/gdscript_docgen.cpp +++ b/modules/gdscript/editor/gdscript_docgen.cpp @@ -140,7 +140,7 @@ void GDScriptDocGen::_doctype_from_gdtype(const GDType &p_gdtype, String &r_type r_enum = String(p_gdtype.native_type).replace("::", "."); if (r_enum.begins_with("res://")) { r_enum = r_enum.trim_prefix("res://"); - int dot_pos = r_enum.rfind("."); + int dot_pos = r_enum.rfind_char('.'); if (dot_pos >= 0) { r_enum = r_enum.left(dot_pos).quote() + r_enum.substr(dot_pos); } diff --git a/modules/gdscript/editor/gdscript_highlighter.cpp b/modules/gdscript/editor/gdscript_highlighter.cpp index 0b12f2ff767..629581bd6c3 100644 --- a/modules/gdscript/editor/gdscript_highlighter.cpp +++ b/modules/gdscript/editor/gdscript_highlighter.cpp @@ -163,7 +163,7 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l } if (from + end_key_length > line_length) { // 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; } } @@ -236,7 +236,7 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting_impl(int p_l for (; from < line_length; from++) { if (line_length - from < end_key_length) { // Don't break if '\' to highlight esc chars. - if (str.find("\\", from) < 0) { + if (str.find_char('\\', from) < 0) { break; } } diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index a29bd1fdb5c..d58cd2c3f79 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -3472,7 +3472,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c } String arg = arg_itr->name; if (arg.contains(":")) { - arg = arg.substr(0, arg.find(":")); + arg = arg.substr(0, arg.find_char(':')); } method_hint += arg; if (use_type_hint) { diff --git a/modules/gltf/editor/editor_scene_importer_blend.cpp b/modules/gltf/editor/editor_scene_importer_blend.cpp index 2db46adef41..5ba9ee3fa6b 100644 --- a/modules/gltf/editor/editor_scene_importer_blend.cpp +++ b/modules/gltf/editor/editor_scene_importer_blend.cpp @@ -80,7 +80,7 @@ static bool _get_blender_version(const String &p_path, int &r_major, int &r_mino } pipe = pipe.substr(bl); pipe = pipe.replace_first("Blender ", ""); - int pp = pipe.find("."); + int pp = pipe.find_char('.'); if (pp == -1) { if (r_err) { *r_err = vformat(TTR("Couldn't extract version information from Blender executable at: %s."), p_path); @@ -96,7 +96,7 @@ static bool _get_blender_version(const String &p_path, int &r_major, int &r_mino return false; } - int pp2 = pipe.find(".", pp + 1); + int pp2 = pipe.find_char('.', pp + 1); r_minor = pp2 > pp ? pipe.substr(pp + 1, pp2 - pp - 1).to_int() : 0; return true; diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index 7cac61304f8..2f36c29ec4a 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -689,7 +689,7 @@ void GLTFDocument::_compute_node_heights(Ref p_state) { } static Vector _parse_base64_uri(const String &p_uri) { - int start = p_uri.find(","); + int start = p_uri.find_char(','); ERR_FAIL_COND_V(start == -1, Vector()); CharString substr = p_uri.substr(start + 1).ascii(); diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 380b401683c..ec9c123f8d8 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -2817,7 +2817,7 @@ Ref ResourceFormatLoaderCSharpScript::load(const String &p_path, const if (p_path.begins_with("csharp://")) { // This is a virtual path used by generic types, extract the real path. real_path = "res://" + p_path.trim_prefix("csharp://"); - real_path = real_path.substr(0, real_path.rfind(":")); + real_path = real_path.substr(0, real_path.rfind_char(':')); } Ref scr; diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index db90ac5a6e2..c54d58d6a01 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -190,7 +190,7 @@ String BindingsGenerator::bbcode_to_text(const String &p_bbcode, const TypeInter int pos = 0; while (pos < bbcode.length()) { - int brk_pos = bbcode.find("[", pos); + int brk_pos = bbcode.find_char('[', pos); if (brk_pos < 0) { brk_pos = bbcode.length(); @@ -210,7 +210,7 @@ String BindingsGenerator::bbcode_to_text(const String &p_bbcode, const TypeInter break; } - int brk_end = bbcode.find("]", brk_pos + 1); + int brk_end = bbcode.find_char(']', brk_pos + 1); if (brk_end == -1) { String text = bbcode.substr(brk_pos, bbcode.length() - brk_pos); @@ -239,7 +239,7 @@ String BindingsGenerator::bbcode_to_text(const String &p_bbcode, const TypeInter output.append("["); pos = brk_pos + 1; } else if (tag.begins_with("method ") || tag.begins_with("constructor ") || tag.begins_with("operator ") || tag.begins_with("member ") || tag.begins_with("signal ") || tag.begins_with("enum ") || tag.begins_with("constant ") || tag.begins_with("theme_item ") || tag.begins_with("param ")) { - const int tag_end = tag.find(" "); + const int tag_end = tag.find_char(' '); const String link_tag = tag.substr(0, tag_end); const String link_target = tag.substr(tag_end + 1, tag.length()).lstrip(" "); @@ -385,7 +385,7 @@ String BindingsGenerator::bbcode_to_text(const String &p_bbcode, const TypeInter pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "url") { - int end = bbcode.find("[", brk_end); + int end = bbcode.find_char('[', brk_end); if (end == -1) { end = bbcode.length(); } @@ -403,7 +403,7 @@ String BindingsGenerator::bbcode_to_text(const String &p_bbcode, const TypeInter pos = brk_end + 1; tag_stack.push_front("url"); } else if (tag == "img") { - int end = bbcode.find("[", brk_end); + int end = bbcode.find_char('[', brk_end); if (end == -1) { end = bbcode.length(); } @@ -455,7 +455,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf int pos = 0; while (pos < bbcode.length()) { - int brk_pos = bbcode.find("[", pos); + int brk_pos = bbcode.find_char('[', pos); if (brk_pos < 0) { brk_pos = bbcode.length(); @@ -488,7 +488,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf break; } - int brk_end = bbcode.find("]", brk_pos + 1); + int brk_end = bbcode.find_char(']', brk_pos + 1); if (brk_end == -1) { if (!line_del) { @@ -551,7 +551,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf xml_output.append("["); pos = brk_pos + 1; } else if (tag.begins_with("method ") || tag.begins_with("constructor ") || tag.begins_with("operator ") || tag.begins_with("member ") || tag.begins_with("signal ") || tag.begins_with("enum ") || tag.begins_with("constant ") || tag.begins_with("theme_item ") || tag.begins_with("param ")) { - const int tag_end = tag.find(" "); + const int tag_end = tag.find_char(' '); const String link_tag = tag.substr(0, tag_end); const String link_target = tag.substr(tag_end + 1, tag.length()).lstrip(" "); @@ -696,7 +696,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "code" || tag.begins_with("code ")) { - int end = bbcode.find("[", brk_end); + int end = bbcode.find_char('[', brk_end); if (end == -1) { end = bbcode.length(); } @@ -751,7 +751,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "url") { - int end = bbcode.find("[", brk_end); + int end = bbcode.find_char('[', brk_end); if (end == -1) { end = bbcode.length(); } @@ -772,7 +772,7 @@ String BindingsGenerator::bbcode_to_xml(const String &p_bbcode, const TypeInterf pos = brk_end + 1; tag_stack.push_front("url"); } else if (tag == "img") { - int end = bbcode.find("[", brk_end); + int end = bbcode.find_char('[', brk_end); if (end == -1) { end = bbcode.length(); } @@ -1619,7 +1619,7 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) { bool enum_in_static_class = false; - if (enum_proxy_name.find(".") > 0) { + if (enum_proxy_name.find_char('.') > 0) { enum_in_static_class = true; String enum_class_name = enum_proxy_name.get_slicec('.', 0); enum_proxy_name = enum_proxy_name.get_slicec('.', 1); diff --git a/modules/mono/editor/code_completion.cpp b/modules/mono/editor/code_completion.cpp index ae914e71ef5..94222f3d67d 100644 --- a/modules/mono/editor/code_completion.cpp +++ b/modules/mono/editor/code_completion.cpp @@ -116,7 +116,7 @@ PackedStringArray get_code_completion(CompletionKind p_kind, const String &p_scr continue; } - String name = prop.name.substr(prop.name.find("/") + 1, prop.name.length()); + String name = prop.name.substr(prop.name.find_char('/') + 1, prop.name.length()); suggestions.push_back(quoted(name)); } } break; diff --git a/modules/mono/utils/path_utils.cpp b/modules/mono/utils/path_utils.cpp index ee17a668d75..068ac8b4e11 100644 --- a/modules/mono/utils/path_utils.cpp +++ b/modules/mono/utils/path_utils.cpp @@ -212,7 +212,7 @@ String relative_to_impl(const String &p_path, const String &p_relative_to) { #ifdef WINDOWS_ENABLED String get_drive_letter(const String &p_norm_path) { int idx = p_norm_path.find(":/"); - if (idx != -1 && idx < p_norm_path.find("/")) { + if (idx != -1 && idx < p_norm_path.find_char('/')) { return p_norm_path.substr(0, idx + 1); } return String(); diff --git a/modules/multiplayer/editor/replication_editor.cpp b/modules/multiplayer/editor/replication_editor.cpp index 8de82ef409a..4d5480eebfe 100644 --- a/modules/multiplayer/editor/replication_editor.cpp +++ b/modules/multiplayer/editor/replication_editor.cpp @@ -375,7 +375,7 @@ void ReplicationEditor::_add_pressed() { return; } - int idx = np_text.find(":"); + int idx = np_text.find_char(':'); if (idx == -1) { np_text = ".:" + np_text; } else if (idx == 0) { @@ -554,7 +554,7 @@ void ReplicationEditor::_add_property(const NodePath &p_property, bool p_spawn, Node *root_node = current && !current->get_root_path().is_empty() ? current->get_node(current->get_root_path()) : nullptr; Ref icon = _get_class_icon(root_node); if (root_node) { - String path = prop.substr(0, prop.find(":")); + String path = prop.substr(0, prop.find_char(':')); String subpath = prop.substr(path.size()); Node *node = root_node->get_node_or_null(path); if (!node) { diff --git a/modules/svg/image_loader_svg.cpp b/modules/svg/image_loader_svg.cpp index b9d493b8440..1f7d5504b6f 100644 --- a/modules/svg/image_loader_svg.cpp +++ b/modules/svg/image_loader_svg.cpp @@ -53,7 +53,7 @@ void ImageLoaderSVG::_replace_color_property(const HashMap &p_colo int pos = r_string.find(p_prefix); while (pos != -1) { pos += prefix_len; // Skip prefix. - int end_pos = r_string.find("\"", pos); + int end_pos = r_string.find_char('"', pos); ERR_FAIL_COND_MSG(end_pos == -1, vformat("Malformed SVG string after property \"%s\".", p_prefix)); const String color_code = r_string.substr(pos, end_pos - pos); if (color_code != "none" && !color_code.begins_with("url(")) { diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index df3142ecbb6..0b506e60d68 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -1564,7 +1564,7 @@ void EditorExportPlatformAndroid::_fix_resources(const Ref & str = get_project_name(package_name); } else { - String lang = str.substr(str.rfind("-") + 1, str.length()).replace("-", "_"); + String lang = str.substr(str.rfind_char('-') + 1, str.length()).replace("-", "_"); if (appnames.has(lang)) { str = appnames[lang]; } else { diff --git a/platform/macos/export/export_plugin.cpp b/platform/macos/export/export_plugin.cpp index bf5645d9a66..b9f9d8d613a 100644 --- a/platform/macos/export/export_plugin.cpp +++ b/platform/macos/export/export_plugin.cpp @@ -970,7 +970,7 @@ Error EditorExportPlatformMacOS::_notarize(const Ref &p_pres return Error::FAILED; } else { print_verbose("rcodesign (" + p_path + "):\n" + str); - int next_nl = str.find("\n", rq_offset); + int next_nl = str.find_char('\n', rq_offset); String request_uuid = (next_nl == -1) ? str.substr(rq_offset + 23, -1) : str.substr(rq_offset + 23, next_nl - rq_offset - 23); add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), vformat(TTR("Notarization request UUID: \"%s\""), request_uuid)); add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), TTR("The notarization process generally takes less than an hour.")); @@ -1054,7 +1054,7 @@ Error EditorExportPlatformMacOS::_notarize(const Ref &p_pres return Error::FAILED; } else { print_verbose("notarytool (" + p_path + "):\n" + str); - int next_nl = str.find("\n", rq_offset); + int next_nl = str.find_char('\n', rq_offset); String request_uuid = (next_nl == -1) ? str.substr(rq_offset + 4, -1) : str.substr(rq_offset + 4, next_nl - rq_offset - 4); add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), vformat(TTR("Notarization request UUID: \"%s\""), request_uuid)); add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), TTR("The notarization process generally takes less than an hour.")); diff --git a/platform/web/api/web_tools_editor_plugin.cpp b/platform/web/api/web_tools_editor_plugin.cpp index d39773bde2d..61801372ba1 100644 --- a/platform/web/api/web_tools_editor_plugin.cpp +++ b/platform/web/api/web_tools_editor_plugin.cpp @@ -80,7 +80,7 @@ void WebToolsEditorPlugin::_download_zip() { const String output_path = String("/tmp").path_join(output_name); zipFile zip = zipOpen2(output_path.utf8().get_data(), APPEND_STATUS_CREATE, nullptr, &io); - const String base_path = resource_path.substr(0, resource_path.rfind("/")) + "/"; + const String base_path = resource_path.substr(0, resource_path.rfind_char('/')) + "/"; _zip_recursive(resource_path, base_path, zip); zipClose(zip, nullptr); { diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index 158155a51c7..e601f16843a 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -50,7 +50,7 @@ void FileDialog::popup_file_dialog() { } void FileDialog::_focus_file_text() { - int lp = file->get_text().rfind("."); + int lp = file->get_text().rfind_char('.'); if (lp != -1) { file->select(0, lp); if (file->is_inside_tree() && !is_part_of_edited_scene()) { @@ -1001,7 +1001,7 @@ void FileDialog::set_current_path(const String &p_path) { if (!p_path.size()) { return; } - int pos = MAX(p_path.rfind("/"), p_path.rfind("\\")); + int pos = MAX(p_path.rfind_char('/'), p_path.rfind_char('\\')); if (pos == -1) { set_current_file(p_path); } else { diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 26141663c1c..a349d502368 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -4845,7 +4845,7 @@ void RichTextLabel::append_text(const String &p_bbcode) { String tooltip; bool size_in_percent = false; if (!bbcode_value.is_empty()) { - int sep = bbcode_value.find("x"); + int sep = bbcode_value.find_char('x'); if (sep == -1) { width = bbcode_value.to_int(); } else { diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp index 85266110935..986bd87af28 100644 --- a/scene/main/http_request.cpp +++ b/scene/main/http_request.cpp @@ -87,7 +87,7 @@ String HTTPRequest::get_header_value(const PackedStringArray &p_headers, const S String lowwer_case_header_name = p_header_name.to_lower(); for (int i = 0; i < p_headers.size(); i++) { - if (p_headers[i].find(":") > 0) { + if (p_headers[i].find_char(':') > 0) { Vector parts = p_headers[i].split(":", false, 1); if (parts.size() > 1 && parts[0].strip_edges().to_lower() == lowwer_case_header_name) { value = parts[1].strip_edges(); diff --git a/scene/property_utils.cpp b/scene/property_utils.cpp index f068e34bebc..9cae7d2a3a8 100644 --- a/scene/property_utils.cpp +++ b/scene/property_utils.cpp @@ -182,7 +182,7 @@ Variant PropertyUtils::get_property_default_value(const Object *p_object, const // Heuristically check if this is a synthetic property (whatever/0, whatever/1, etc.) // because they are not in the class DB yet must have a default (null). String prop_str = String(p_property); - int p = prop_str.rfind("/"); + int p = prop_str.rfind_char('/'); if (p != -1 && p < prop_str.length() - 1) { bool all_digits = true; for (int i = p + 1; i < prop_str.length(); i++) { diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index a4677d917db..ae70443e6af 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 *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 keys; @@ -1744,7 +1744,7 @@ Error FontFile::_load_bitmap_font(const String &p_path, List *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 *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 b0353b4f2c7..8c0e0879029 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 809a77a4872..d7036fd6d51 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 6e03fe25c9d..03f0e107e4d 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, 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 da90ba1ef2b..4bc03a049a9 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; } }