From a0dbdcc3abbd3e6307c6e68d0e60f8c0fa31d576 Mon Sep 17 00:00:00 2001 From: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> Date: Mon, 6 May 2024 16:20:20 +0200 Subject: [PATCH] Replace `find` with `contains/has` where applicable * Replaces `find(...) != -1` with `contains` for `String` * Replaces `find(...) == -1` with `!contains` for `String` * Replaces `find(...) != -1` with `has` for containers * Replaces `find(...) == -1` with `!has` for containers --- core/debugger/engine_debugger.cpp | 2 +- core/extension/extension_api_dump.cpp | 2 +- core/io/ip_address.cpp | 2 +- core/string/ustring.cpp | 2 +- drivers/alsa/audio_driver_alsa.cpp | 2 +- drivers/egl/egl_manager.cpp | 2 +- .../pulseaudio/audio_driver_pulseaudio.cpp | 4 +- editor/create_dialog.cpp | 2 +- .../debug_adapter/debug_adapter_parser.cpp | 2 +- editor/debugger/editor_debugger_node.cpp | 2 +- editor/debugger/editor_file_server.cpp | 2 +- editor/dependency_editor.cpp | 4 +- editor/doc_tools.cpp | 2 +- editor/editor_file_system.cpp | 4 +- editor/editor_help_search.cpp | 2 +- editor/editor_node.cpp | 2 +- editor/editor_property_name_processor.cpp | 2 +- editor/editor_quick_open.cpp | 2 +- editor/editor_settings.cpp | 4 +- editor/filesystem_dock.cpp | 6 +- editor/import/3d/resource_importer_obj.cpp | 2 +- editor/import/3d/resource_importer_scene.cpp | 8 +- editor/plugins/script_editor_plugin.cpp | 2 +- .../plugins/sprite_frames_editor_plugin.cpp | 2 +- editor/rename_dialog.cpp | 2 +- editor/scene_tree_dock.cpp | 2 +- main/main.cpp | 2 +- modules/csg/csg.cpp | 2 +- .../language_server/gdscript_workspace.cpp | 2 +- modules/gdscript/tests/test_lsp.h | 2 +- modules/gltf/gltf_document.cpp | 2 +- modules/gltf/skin_tool.cpp | 24 ++-- modules/mono/editor/bindings_generator.cpp | 6 +- .../openxr/action_map/openxr_action_map.cpp | 8 +- .../openxr/action_map/openxr_action_set.cpp | 2 +- .../action_map/openxr_interaction_profile.cpp | 2 +- modules/openxr/openxr_interface.cpp | 2 +- modules/regex/regex.cpp | 2 +- modules/text_server_adv/text_server_adv.h | 40 +++---- modules/text_server_fb/text_server_fb.h | 40 +++---- modules/upnp/upnp.cpp | 8 +- platform/android/export/export_plugin.cpp | 8 +- platform/android/os_android.cpp | 4 +- platform/ios/export/export_plugin.cpp | 106 +++++++++--------- platform/linuxbsd/joypad_linux.cpp | 6 +- platform/linuxbsd/os_linuxbsd.cpp | 4 +- platform/macos/export/export_plugin.cpp | 46 ++++---- platform/windows/export/export_plugin.cpp | 14 +-- scene/3d/skeleton_3d.cpp | 2 +- scene/gui/texture_progress_bar.cpp | 2 +- scene/resources/mesh.cpp | 2 +- servers/audio/audio_stream.cpp | 2 +- servers/rendering/rendering_device.cpp | 8 +- tests/core/object/test_class_db.h | 12 +- tests/test_main.cpp | 8 +- 55 files changed, 219 insertions(+), 219 deletions(-) diff --git a/core/debugger/engine_debugger.cpp b/core/debugger/engine_debugger.cpp index a7655c874a0..97a020e4c36 100644 --- a/core/debugger/engine_debugger.cpp +++ b/core/debugger/engine_debugger.cpp @@ -137,7 +137,7 @@ void EngineDebugger::initialize(const String &p_uri, bool p_skip_breakpoints, co script_debugger = memnew(ScriptDebugger); // Tell the OS that we want to handle termination signals. OS::get_singleton()->initialize_debugging(); - } else if (p_uri.find("://") >= 0) { + } else if (p_uri.contains("://")) { const String proto = p_uri.substr(0, p_uri.find("://") + 3); if (!protocols.has(proto)) { return; diff --git a/core/extension/extension_api_dump.cpp b/core/extension/extension_api_dump.cpp index 1c9b4dc3e8e..848b6f3886e 100644 --- a/core/extension/extension_api_dump.cpp +++ b/core/extension/extension_api_dump.cpp @@ -1201,7 +1201,7 @@ Dictionary GDExtensionAPIDump::generate_extension_api(bool p_include_docs) { if (F.name.begins_with("_")) { continue; //hidden property } - if (F.name.find("/") >= 0) { + if (F.name.contains("/")) { // Ignore properties with '/' (slash) in the name. These are only meant for use in the inspector. continue; } diff --git a/core/io/ip_address.cpp b/core/io/ip_address.cpp index ce74bb36d6b..a93876a2b51 100644 --- a/core/io/ip_address.cpp +++ b/core/io/ip_address.cpp @@ -202,7 +202,7 @@ IPAddress::IPAddress(const String &p_string) { // Wildcard (not a valid IP) wildcard = true; - } else if (p_string.find(":") >= 0) { + } else if (p_string.contains(":")) { // IPv6 _parse_ipv6(p_string); valid = true; diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index 7cd1a39d38c..3d37e17ef83 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -3964,7 +3964,7 @@ String String::format(const Variant &values, const String &placeholder) const { Variant v_val = values_arr[i]; String val = v_val; - if (placeholder.find("_") > -1) { + if (placeholder.contains("_")) { new_string = new_string.replace(placeholder.replace("_", i_as_str), val); } else { new_string = new_string.replace_first(placeholder, val); diff --git a/drivers/alsa/audio_driver_alsa.cpp b/drivers/alsa/audio_driver_alsa.cpp index 764d66c3b8d..0c9635339bb 100644 --- a/drivers/alsa/audio_driver_alsa.cpp +++ b/drivers/alsa/audio_driver_alsa.cpp @@ -52,7 +52,7 @@ Error AudioDriverALSA::init_output_device() { // If there is a specified output device check that it is really present if (output_device_name != "Default") { PackedStringArray list = get_output_device_list(); - if (list.find(output_device_name) == -1) { + if (!list.has(output_device_name)) { output_device_name = "Default"; new_output_device = "Default"; } diff --git a/drivers/egl/egl_manager.cpp b/drivers/egl/egl_manager.cpp index 4eddfd027b9..6073856747a 100644 --- a/drivers/egl/egl_manager.cpp +++ b/drivers/egl/egl_manager.cpp @@ -383,7 +383,7 @@ Error EGLManager::initialize() { ERR_FAIL_COND_V(eglGetError() != EGL_SUCCESS, ERR_BUG); const char *platform = _get_platform_extension_name(); - if (extensions_string.split(" ").find(platform) < 0) { + if (!extensions_string.split(" ").has(platform)) { ERR_FAIL_V_MSG(ERR_UNAVAILABLE, vformat("EGL platform extension \"%s\" not found.", platform)); } diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.cpp b/drivers/pulseaudio/audio_driver_pulseaudio.cpp index 20382e7f7c3..669e6c2aa95 100644 --- a/drivers/pulseaudio/audio_driver_pulseaudio.cpp +++ b/drivers/pulseaudio/audio_driver_pulseaudio.cpp @@ -183,7 +183,7 @@ Error AudioDriverPulseAudio::init_output_device() { // If there is a specified output device, check that it is really present if (output_device_name != "Default") { PackedStringArray list = get_output_device_list(); - if (list.find(output_device_name) == -1) { + if (!list.has(output_device_name)) { output_device_name = "Default"; new_output_device = "Default"; } @@ -695,7 +695,7 @@ Error AudioDriverPulseAudio::init_input_device() { // If there is a specified input device, check that it is really present if (input_device_name != "Default") { PackedStringArray list = get_input_device_list(); - if (list.find(input_device_name) == -1) { + if (!list.has(input_device_name)) { input_device_name = "Default"; new_input_device = "Default"; } diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index b00f059b36c..2c7f6fb21ac 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -376,7 +376,7 @@ float CreateDialog::_score_type(const String &p_type, const String &p_search) co score *= _is_type_preferred(p_type) ? 1.0f : 0.9f; // Add score for being a favorite type. - score *= (favorite_list.find(p_type) > -1) ? 1.0f : 0.8f; + score *= favorite_list.has(p_type) ? 1.0f : 0.8f; // Look through at most 5 recent items bool in_recent = false; diff --git a/editor/debugger/debug_adapter/debug_adapter_parser.cpp b/editor/debugger/debug_adapter/debug_adapter_parser.cpp index 3c0420d2f02..4210baeed2d 100644 --- a/editor/debugger/debug_adapter/debug_adapter_parser.cpp +++ b/editor/debugger/debug_adapter/debug_adapter_parser.cpp @@ -358,7 +358,7 @@ Dictionary DebugAdapterParser::req_setBreakpoints(const Dictionary &p_params) co } // If path contains \, it's a Windows path, so we need to convert it to /, and make the drive letter uppercase - if (source.path.find("\\") != -1) { + if (source.path.contains("\\")) { source.path = source.path.replace("\\", "/"); source.path = source.path.substr(0, 1).to_upper() + source.path.substr(1); } diff --git a/editor/debugger/editor_debugger_node.cpp b/editor/debugger/editor_debugger_node.cpp index 3ee8a33e709..931e360a348 100644 --- a/editor/debugger/editor_debugger_node.cpp +++ b/editor/debugger/editor_debugger_node.cpp @@ -262,7 +262,7 @@ void EditorDebuggerNode::set_keep_open(bool p_keep_open) { } Error EditorDebuggerNode::start(const String &p_uri) { - ERR_FAIL_COND_V(p_uri.find("://") < 0, ERR_INVALID_PARAMETER); + ERR_FAIL_COND_V(!p_uri.contains("://"), ERR_INVALID_PARAMETER); if (keep_open && current_uri == p_uri && server.is_valid()) { return OK; } diff --git a/editor/debugger/editor_file_server.cpp b/editor/debugger/editor_file_server.cpp index e84eb146363..1092b070542 100644 --- a/editor/debugger/editor_file_server.cpp +++ b/editor/debugger/editor_file_server.cpp @@ -80,7 +80,7 @@ void EditorFileServer::_scan_files_changed(EditorFileSystemDirectory *efd, const _add_file(remapped_path, mt, files_to_send, cached_files); } else if (remap.begins_with("path.")) { String feature = remap.get_slice(".", 1); - if (p_tags.find(feature) != -1) { + if (p_tags.has(feature)) { String remapped_path = cf->get_value("remap", remap); uint64_t mt = FileAccess::get_modified_time(remapped_path); _add_file(remapped_path, mt, files_to_send, cached_files); diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp index 8c3cad3e890..84d6cb67d8f 100644 --- a/editor/dependency_editor.cpp +++ b/editor/dependency_editor.cpp @@ -642,11 +642,11 @@ void DependencyRemoveDialog::ok_pressed() { for (int i = 0; i < previous_favorites.size(); ++i) { if (previous_favorites[i].ends_with("/")) { - if (dirs_to_delete.find(previous_favorites[i]) < 0) { + if (!dirs_to_delete.has(previous_favorites[i])) { new_favorites.push_back(previous_favorites[i]); } } else { - if (files_to_delete.find(previous_favorites[i]) < 0) { + if (!files_to_delete.has(previous_favorites[i])) { new_favorites.push_back(previous_favorites[i]); } } diff --git a/editor/doc_tools.cpp b/editor/doc_tools.cpp index 7fce3c45f8f..b58e82b7e74 100644 --- a/editor/doc_tools.cpp +++ b/editor/doc_tools.cpp @@ -1638,7 +1638,7 @@ Error DocTools::save_classes(const String &p_default_path, const HashMap p_query) { - ERR_FAIL_COND(import_support_queries.find(p_query) != -1); + ERR_FAIL_COND(import_support_queries.has(p_query)); import_support_queries.push_back(p_query); } void EditorFileSystem::remove_import_format_support_query(Ref p_query) { diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp index ff381d68c05..02b51460529 100644 --- a/editor/editor_help_search.cpp +++ b/editor/editor_help_search.cpp @@ -744,7 +744,7 @@ String EditorHelpSearch::Runner::_match_keywords_in_all_terms(const String &p_ke bool EditorHelpSearch::Runner::_match_string(const String &p_term, const String &p_string) const { if (search_flags & SEARCH_CASE_SENSITIVE) { - return p_string.find(p_term) > -1; + return p_string.contains(p_term); } else { return p_string.findn(p_term) > -1; } diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 33b46b82bc9..b501835cd16 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -2391,7 +2391,7 @@ void EditorNode::_edit_current(bool p_skip_foreign, bool p_skip_inspector_update Ref res = Object::cast_to(current_obj); if (p_skip_foreign && res.is_valid()) { const int current_tab = scene_tabs->get_current_tab(); - if (res->get_path().find("::") > -1 && res->get_path().get_slice("::", 0) != editor_data.get_scene_path(current_tab)) { + if (res->get_path().contains("::") && res->get_path().get_slice("::", 0) != editor_data.get_scene_path(current_tab)) { // Trying to edit resource that belongs to another scene; abort. current_obj = nullptr; } diff --git a/editor/editor_property_name_processor.cpp b/editor/editor_property_name_processor.cpp index a00b50c191f..f23cab676cc 100644 --- a/editor/editor_property_name_processor.cpp +++ b/editor/editor_property_name_processor.cpp @@ -63,7 +63,7 @@ bool EditorPropertyNameProcessor::is_localization_available() { return false; } const Vector forbidden = String("en").split(","); - return forbidden.find(EDITOR_GET("interface/editor/editor_language")) == -1; + return !forbidden.has(EDITOR_GET("interface/editor/editor_language")); } String EditorPropertyNameProcessor::_capitalize_name(const String &p_name) const { diff --git a/editor/editor_quick_open.cpp b/editor/editor_quick_open.cpp index f8df0f9fa86..d7a02ace24f 100644 --- a/editor/editor_quick_open.cpp +++ b/editor/editor_quick_open.cpp @@ -160,7 +160,7 @@ float EditorQuickOpen::_score_search_result(const PackedStringArray &p_search_to } // Prioritize matches at the front of the path token. - if (min_match_idx == 0 || p_path.find("/" + s) != -1) { + if (min_match_idx == 0 || p_path.contains("/" + s)) { token_score += 1.0f; } diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index d1aa69294e4..e3dfbc45e82 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -969,7 +969,7 @@ bool EditorSettings::_save_text_editor_theme(const String &p_file) { keys.sort(); for (const String &key : keys) { - if (key.begins_with("text_editor/theme/highlighting/") && key.find("color") >= 0) { + if (key.begins_with("text_editor/theme/highlighting/") && key.contains("color")) { cf->set_value(theme_section, key.replace("text_editor/theme/highlighting/", ""), ((Color)props[key].variant).to_html()); } } @@ -1448,7 +1448,7 @@ void EditorSettings::load_text_editor_theme() { // don't load if it's not already there! if (has_setting("text_editor/theme/highlighting/" + key)) { // make sure it is actually a color - if (val.is_valid_html_color() && key.find("color") >= 0) { + if (val.is_valid_html_color() && key.contains("color")) { props["text_editor/theme/highlighting/" + key].variant = Color::html(val); // change manually to prevent "Settings changed" console spam } } diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index ef77e5340bc..4c7c723dd5c 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -261,7 +261,7 @@ bool FileSystemDock::_create_tree(TreeItem *p_parent, EditorFileSystemDirectory if (p_unfold_path && current_path.begins_with(lpath) && current_path != lpath) { subdirectory_item->set_collapsed(false); } else { - subdirectory_item->set_collapsed(uncollapsed_paths.find(lpath) < 0); + subdirectory_item->set_collapsed(!uncollapsed_paths.has(lpath)); } if (!searched_tokens.is_empty() && _matches_all_search_tokens(dname)) { parent_should_expand = true; @@ -407,7 +407,7 @@ void FileSystemDock::_update_tree(const Vector &p_uncollapsed_paths, boo favorites_item->set_icon(0, get_editor_theme_icon(SNAME("Favorites"))); favorites_item->set_text(0, TTR("Favorites:")); favorites_item->set_metadata(0, "Favorites"); - favorites_item->set_collapsed(p_uncollapsed_paths.find("Favorites") < 0); + favorites_item->set_collapsed(!p_uncollapsed_paths.has("Favorites")); Vector favorite_paths = EditorSettings::get_singleton()->get_favorites(); @@ -2300,7 +2300,7 @@ void FileSystemDock::_file_option(int p_option, const Vector &p_selected TreeItem *selected = tree->get_root(); selected = tree->get_next_selected(selected); while (selected) { - if (p_selected.find(selected->get_metadata(0)) >= 0) { + if (p_selected.has(selected->get_metadata(0))) { selected->set_collapsed(false); } selected = tree->get_next_selected(selected); diff --git a/editor/import/3d/resource_importer_obj.cpp b/editor/import/3d/resource_importer_obj.cpp index f5bf60175ab..6d68e93c756 100644 --- a/editor/import/3d/resource_importer_obj.cpp +++ b/editor/import/3d/resource_importer_obj.cpp @@ -217,7 +217,7 @@ static Error _parse_obj(const String &p_path, List> &r_meshes, 0x14c, // IMAGE_FILE_MACHINE_I386 0x200, // IMAGE_FILE_MACHINE_IA64 }; - ERR_FAIL_COND_V_MSG(coff_header_machines.find(first_bytes) != -1, ERR_FILE_CORRUPT, vformat("Couldn't read OBJ file '%s', it seems to be binary, corrupted, or empty.", p_path)); + ERR_FAIL_COND_V_MSG(coff_header_machines.has(first_bytes), ERR_FILE_CORRUPT, vformat("Couldn't read OBJ file '%s', it seems to be binary, corrupted, or empty.", p_path)); f->seek(0); Ref mesh; diff --git a/editor/import/3d/resource_importer_scene.cpp b/editor/import/3d/resource_importer_scene.cpp index 707be843811..077625b3f16 100644 --- a/editor/import/3d/resource_importer_scene.cpp +++ b/editor/import/3d/resource_importer_scene.cpp @@ -2086,12 +2086,12 @@ bool ResourceImporterScene::get_internal_option_visibility(InternalImportCategor p_options.has("generate/physics") && p_options["generate/physics"].operator bool(); - if (p_option.find("physics/") >= 0) { + if (p_option.contains("physics/")) { // Show if need to generate collisions. return generate_physics; } - if (p_option.find("decomposition/") >= 0) { + if (p_option.contains("decomposition/")) { // Show if need to generate collisions. if (generate_physics && // Show if convex is enabled. @@ -2285,8 +2285,8 @@ bool ResourceImporterScene::get_internal_option_update_view_required(InternalImp if ( p_option == "generate/physics" || p_option == "physics/shape_type" || - p_option.find("decomposition/") >= 0 || - p_option.find("primitive/") >= 0) { + p_option.contains("decomposition/") || + p_option.contains("primitive/")) { return true; } } break; diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 2f479527f3b..e1de10284ac 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -742,7 +742,7 @@ void ScriptEditor::_add_recent_script(const String &p_path) { } Array rc = EditorSettings::get_singleton()->get_project_metadata("recent_files", "scripts", Array()); - if (rc.find(p_path) != -1) { + if (rc.has(p_path)) { rc.erase(p_path); } rc.push_front(p_path); diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index a28952d8e77..eef9557ca8d 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -1312,7 +1312,7 @@ void SpriteFramesEditor::_update_library_impl() { TreeItem *selected = nullptr; for (const StringName &E : anim_names) { String name = E; - if (searching && name.to_lower().find(searched_string) < 0) { + if (searching && !name.to_lower().contains(searched_string)) { continue; } TreeItem *it = animations->create_item(anim_root); diff --git a/editor/rename_dialog.cpp b/editor/rename_dialog.cpp index 9fca334e7c9..45c437b5f35 100644 --- a/editor/rename_dialog.cpp +++ b/editor/rename_dialog.cpp @@ -473,7 +473,7 @@ void RenameDialog::_error_handler(void *p_self, const char *p_func, const char * String source_file = String::utf8(p_file); // Only show first error that is related to "regex" - if (self->has_errors || source_file.find("regex") < 0) { + if (self->has_errors || !source_file.contains("regex")) { return; } diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index ee2a43bd557..3a1de937e26 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -1297,7 +1297,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { } StringName name = node->get_name(); - if (new_unique_names.find(name) != -1 || get_tree()->get_edited_scene_root()->get_node_or_null(UNIQUE_NODE_PREFIX + String(name)) != nullptr) { + if (new_unique_names.has(name) || get_tree()->get_edited_scene_root()->get_node_or_null(UNIQUE_NODE_PREFIX + String(name)) != nullptr) { cant_be_set_unique_names.push_back(name); } else { new_unique_nodes.push_back(node); diff --git a/main/main.cpp b/main/main.cpp index e30584ebb97..1ba336221fa 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -2993,7 +2993,7 @@ Error Main::setup2() { // Dummy text driver cannot draw any text, making the editor unusable if selected. continue; } - if (!text_driver_options.is_empty() && text_driver_options.find(",") == -1) { + if (!text_driver_options.is_empty() && !text_driver_options.contains(",")) { // Not the first option; add a comma before it as a separator for the property hint. text_driver_options += ","; } diff --git a/modules/csg/csg.cpp b/modules/csg/csg.cpp index cec03b7246d..a4a3c768e94 100644 --- a/modules/csg/csg.cpp +++ b/modules/csg/csg.cpp @@ -852,7 +852,7 @@ int CSGBrushOperation::Build2DFaces::_add_vertex(const Vertex2D &p_vertex) { } void CSGBrushOperation::Build2DFaces::_add_vertex_idx_sorted(Vector &r_vertex_indices, int p_new_vertex_index) { - if (p_new_vertex_index >= 0 && r_vertex_indices.find(p_new_vertex_index) == -1) { + if (p_new_vertex_index >= 0 && !r_vertex_indices.has(p_new_vertex_index)) { ERR_FAIL_COND_MSG(p_new_vertex_index >= vertices.size(), "Invalid vertex index."); // The first vertex. diff --git a/modules/gdscript/language_server/gdscript_workspace.cpp b/modules/gdscript/language_server/gdscript_workspace.cpp index 819611099e9..09defdf8cd7 100644 --- a/modules/gdscript/language_server/gdscript_workspace.cpp +++ b/modules/gdscript/language_server/gdscript_workspace.cpp @@ -695,7 +695,7 @@ const lsp::DocumentSymbol *GDScriptWorkspace::resolve_symbol(const lsp::TextDocu } else { ScriptLanguage::LookupResult ret; - if (symbol_identifier == "new" && parser->get_lines()[p_doc_pos.position.line].replace(" ", "").replace("\t", "").find("new(") > -1) { + if (symbol_identifier == "new" && parser->get_lines()[p_doc_pos.position.line].replace(" ", "").replace("\t", "").contains("new(")) { symbol_identifier = "_init"; } if (OK == GDScriptLanguage::get_singleton()->lookup_code(parser->get_text_for_lookup_symbol(pos, symbol_identifier, p_func_required), symbol_identifier, path, nullptr, ret)) { diff --git a/modules/gdscript/tests/test_lsp.h b/modules/gdscript/tests/test_lsp.h index 6192272f806..b85c727bc5b 100644 --- a/modules/gdscript/tests/test_lsp.h +++ b/modules/gdscript/tests/test_lsp.h @@ -227,7 +227,7 @@ Vector read_tests(const String &p_path) { if (InlineTestData::try_parse(lines, i, d)) { if (!d.name.is_empty()) { // Safety check: names must be unique. - if (names.find(d.name) != -1) { + if (names.has(d.name)) { FAIL(vformat("Duplicated name '%s' in '%s'. Names must be unique!", d.name, p_path)); } names.append(d.name); diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp index 4c32a29ce00..575702bc544 100644 --- a/modules/gltf/gltf_document.cpp +++ b/modules/gltf/gltf_document.cpp @@ -7032,7 +7032,7 @@ void GLTFDocument::_build_parent_hierachy(Ref p_state) { Vector> GLTFDocument::all_document_extensions; void GLTFDocument::register_gltf_document_extension(Ref p_extension, bool p_first_priority) { - if (all_document_extensions.find(p_extension) == -1) { + if (!all_document_extensions.has(p_extension)) { if (p_first_priority) { all_document_extensions.insert(0, p_extension); } else { diff --git a/modules/gltf/skin_tool.cpp b/modules/gltf/skin_tool.cpp index 2fb55a5f9eb..a344334d939 100644 --- a/modules/gltf/skin_tool.cpp +++ b/modules/gltf/skin_tool.cpp @@ -57,9 +57,9 @@ bool SkinTool::_capture_nodes_in_skin(const Vector> &nodes, Refjoint && p_skin->joints.find(p_node_index) < 0) { + if (current_node->joint && !p_skin->joints.has(p_node_index)) { p_skin->joints.push_back(p_node_index); - } else if (p_skin->non_joints.find(p_node_index) < 0) { + } else if (!p_skin->non_joints.has(p_node_index)) { p_skin->non_joints.push_back(p_node_index); } } @@ -79,7 +79,7 @@ void SkinTool::_capture_nodes_for_multirooted_skin(Vector> &r_node const SkinNodeIndex parent = r_nodes[node_index]->parent; disjoint_set.insert(node_index); - if (p_skin->joints.find(parent) >= 0) { + if (p_skin->joints.has(parent)) { disjoint_set.create_union(parent, node_index); } } @@ -109,9 +109,9 @@ void SkinTool::_capture_nodes_for_multirooted_skin(Vector> &r_node while (r_nodes[current_node]->height > maxHeight) { SkinNodeIndex parent = r_nodes[current_node]->parent; - if (r_nodes[parent]->joint && p_skin->joints.find(parent) < 0) { + if (r_nodes[parent]->joint && !p_skin->joints.has(parent)) { p_skin->joints.push_back(parent); - } else if (p_skin->non_joints.find(parent) < 0) { + } else if (!p_skin->non_joints.has(parent)) { p_skin->non_joints.push_back(parent); } @@ -138,9 +138,9 @@ void SkinTool::_capture_nodes_for_multirooted_skin(Vector> &r_node const SkinNodeIndex current_node = roots[i]; const SkinNodeIndex parent = r_nodes[current_node]->parent; - if (r_nodes[parent]->joint && p_skin->joints.find(parent) < 0) { + if (r_nodes[parent]->joint && !p_skin->joints.has(parent)) { p_skin->joints.push_back(parent); - } else if (p_skin->non_joints.find(parent) < 0) { + } else if (!p_skin->non_joints.has(parent)) { p_skin->non_joints.push_back(parent); } @@ -166,7 +166,7 @@ Error SkinTool::_expand_skin(Vector> &r_nodes, Ref p_ski const SkinNodeIndex parent = r_nodes[node_index]->parent; disjoint_set.insert(node_index); - if (all_skin_nodes.find(parent) >= 0) { + if (all_skin_nodes.has(parent)) { disjoint_set.create_union(parent, node_index); } } @@ -216,7 +216,7 @@ Error SkinTool::_verify_skin(Vector> &r_nodes, Ref p_ski const SkinNodeIndex parent = r_nodes[node_index]->parent; disjoint_set.insert(node_index); - if (all_skin_nodes.find(parent) >= 0) { + if (all_skin_nodes.has(parent)) { disjoint_set.create_union(parent, node_index); } } @@ -365,7 +365,7 @@ Error SkinTool::_determine_skeletons( for (int j = 0; j < groups.size() && i != j; ++j) { const Vector &group = groups[j]; - if (group.find(node_i_parent) >= 0) { + if (group.has(node_i_parent)) { const SkinNodeIndex node_j = highest_group_members[j]; skeleton_sets.create_union(node_i, node_j); } @@ -393,7 +393,7 @@ Error SkinTool::_determine_skeletons( // If any of the the skeletons nodes exist in a skin, that skin now maps to the skeleton for (int i = 0; i < skeleton_nodes.size(); ++i) { SkinNodeIndex skel_node_i = skeleton_nodes[i]; - if (skin->joints.find(skel_node_i) >= 0 || skin->non_joints.find(skel_node_i) >= 0) { + if (skin->joints.has(skel_node_i) || skin->non_joints.has(skel_node_i)) { skin->skeleton = skel_i; continue; } @@ -454,7 +454,7 @@ Error SkinTool::_reparent_non_joint_skeleton_subtrees( subtree_set.insert(node_i); const SkinNodeIndex parent_i = nodes[node_i]->parent; - if (parent_i >= 0 && p_non_joints.find(parent_i) >= 0 && !nodes[parent_i]->joint) { + if (parent_i >= 0 && p_non_joints.has(parent_i) && !nodes[parent_i]->joint) { subtree_set.create_union(parent_i, node_i); } } diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index eb75f05a235..9a76a256395 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -873,7 +873,7 @@ void BindingsGenerator::_append_text_method(StringBuilder &p_output, const TypeI } void BindingsGenerator::_append_text_member(StringBuilder &p_output, const TypeInterface *p_target_itype, const StringName &p_target_cname, const String &p_link_target, const Vector &p_link_target_parts) { - if (p_link_target.find("/") >= 0) { + if (p_link_target.contains("/")) { // Properties with '/' (slash) in the name are not declared in C#, so there is nothing to reference. _append_text_undeclared(p_output, p_link_target); } else if (!p_target_itype || !p_target_itype->is_object_type) { @@ -1154,7 +1154,7 @@ void BindingsGenerator::_append_xml_method(StringBuilder &p_xml_output, const Ty } void BindingsGenerator::_append_xml_member(StringBuilder &p_xml_output, const TypeInterface *p_target_itype, const StringName &p_target_cname, const String &p_link_target, const Vector &p_link_target_parts) { - if (p_link_target.find("/") >= 0) { + if (p_link_target.contains("/")) { // Properties with '/' (slash) in the name are not declared in C#, so there is nothing to reference. _append_xml_undeclared(p_xml_output, p_link_target); } else if (!p_target_itype || !p_target_itype->is_object_type) { @@ -3654,7 +3654,7 @@ bool BindingsGenerator::_populate_object_type_interfaces() { continue; } - if (property.name.find("/") >= 0) { + if (property.name.contains("/")) { // Ignore properties with '/' (slash) in the name. These are only meant for use in the inspector. continue; } diff --git a/modules/openxr/action_map/openxr_action_map.cpp b/modules/openxr/action_map/openxr_action_map.cpp index ba0e4f6cdd3..5430a41d6d6 100644 --- a/modules/openxr/action_map/openxr_action_map.cpp +++ b/modules/openxr/action_map/openxr_action_map.cpp @@ -59,7 +59,7 @@ void OpenXRActionMap::set_action_sets(Array p_action_sets) { for (int i = 0; i < p_action_sets.size(); i++) { Ref action_set = p_action_sets[i]; - if (action_set.is_valid() && action_sets.find(action_set) == -1) { + if (action_set.is_valid() && !action_sets.has(action_set)) { action_sets.push_back(action_set); } } @@ -93,7 +93,7 @@ Ref OpenXRActionMap::get_action_set(int p_idx) const { void OpenXRActionMap::add_action_set(Ref p_action_set) { ERR_FAIL_COND(p_action_set.is_null()); - if (action_sets.find(p_action_set) == -1) { + if (!action_sets.has(p_action_set)) { action_sets.push_back(p_action_set); emit_changed(); } @@ -112,7 +112,7 @@ void OpenXRActionMap::set_interaction_profiles(Array p_interaction_profiles) { for (int i = 0; i < p_interaction_profiles.size(); i++) { Ref interaction_profile = p_interaction_profiles[i]; - if (interaction_profile.is_valid() && interaction_profiles.find(interaction_profile) == -1) { + if (interaction_profile.is_valid() && !interaction_profiles.has(interaction_profile)) { interaction_profiles.push_back(interaction_profile); } } @@ -146,7 +146,7 @@ Ref OpenXRActionMap::get_interaction_profile(int p_idx void OpenXRActionMap::add_interaction_profile(Ref p_interaction_profile) { ERR_FAIL_COND(p_interaction_profile.is_null()); - if (interaction_profiles.find(p_interaction_profile) == -1) { + if (!interaction_profiles.has(p_interaction_profile)) { interaction_profiles.push_back(p_interaction_profile); emit_changed(); } diff --git a/modules/openxr/action_map/openxr_action_set.cpp b/modules/openxr/action_map/openxr_action_set.cpp index 4855f9e4b71..d583af2b2f2 100644 --- a/modules/openxr/action_map/openxr_action_set.cpp +++ b/modules/openxr/action_map/openxr_action_set.cpp @@ -124,7 +124,7 @@ Ref OpenXRActionSet::get_action(const String p_name) const { void OpenXRActionSet::add_action(Ref p_action) { ERR_FAIL_COND(p_action.is_null()); - if (actions.find(p_action) == -1) { + if (!actions.has(p_action)) { if (p_action->action_set && p_action->action_set != this) { // action should only relate to our action set p_action->action_set->remove_action(p_action); diff --git a/modules/openxr/action_map/openxr_interaction_profile.cpp b/modules/openxr/action_map/openxr_interaction_profile.cpp index 65ee6527322..2579697d054 100644 --- a/modules/openxr/action_map/openxr_interaction_profile.cpp +++ b/modules/openxr/action_map/openxr_interaction_profile.cpp @@ -172,7 +172,7 @@ Ref OpenXRInteractionProfile::get_binding_for_action(const Ref< void OpenXRInteractionProfile::add_binding(Ref p_binding) { ERR_FAIL_COND(p_binding.is_null()); - if (bindings.find(p_binding) == -1) { + if (!bindings.has(p_binding)) { ERR_FAIL_COND_MSG(get_binding_for_action(p_binding->get_action()).is_valid(), "There is already a binding for this action in this interaction profile"); bindings.push_back(p_binding); diff --git a/modules/openxr/openxr_interface.cpp b/modules/openxr/openxr_interface.cpp index b92d1edb90f..fbbc61a91ce 100644 --- a/modules/openxr/openxr_interface.cpp +++ b/modules/openxr/openxr_interface.cpp @@ -391,7 +391,7 @@ OpenXRInterface::Action *OpenXRInterface::create_action(ActionSet *p_action_set, // we link our actions back to our trackers so we know which actions to check when we're processing our trackers for (int i = 0; i < p_trackers.size(); i++) { - if (p_trackers[i]->actions.find(action) == -1) { + if (!p_trackers[i]->actions.has(action)) { p_trackers[i]->actions.push_back(action); } } diff --git a/modules/regex/regex.cpp b/modules/regex/regex.cpp index 4a1037431a5..9f34a6ca6a8 100644 --- a/modules/regex/regex.cpp +++ b/modules/regex/regex.cpp @@ -370,7 +370,7 @@ PackedStringArray RegEx::get_names() const { for (uint32_t i = 0; i < count; i++) { String name = &table[i * entry_size + 1]; - if (result.find(name) < 0) { + if (!result.has(name)) { result.append(name); } } diff --git a/modules/text_server_adv/text_server_adv.h b/modules/text_server_adv/text_server_adv.h index 7e29f984c16..8895a83089a 100644 --- a/modules/text_server_adv/text_server_adv.h +++ b/modules/text_server_adv/text_server_adv.h @@ -389,54 +389,54 @@ class TextServerAdvanced : public TextServerExtension { _FORCE_INLINE_ bool _get_tag_hidden(int64_t p_tag) const; _FORCE_INLINE_ int _font_get_weight_by_name(const String &p_sty_name) const { String sty_name = p_sty_name.replace(" ", "").replace("-", ""); - if (sty_name.find("thin") >= 0 || sty_name.find("hairline") >= 0) { + if (sty_name.contains("thin") || sty_name.contains("hairline")) { return 100; - } else if (sty_name.find("extralight") >= 0 || sty_name.find("ultralight") >= 0) { + } else if (sty_name.contains("extralight") || sty_name.contains("ultralight")) { return 200; - } else if (sty_name.find("light") >= 0) { + } else if (sty_name.contains("light")) { return 300; - } else if (sty_name.find("semilight") >= 0) { + } else if (sty_name.contains("semilight")) { return 350; - } else if (sty_name.find("regular") >= 0) { + } else if (sty_name.contains("regular")) { return 400; - } else if (sty_name.find("medium") >= 0) { + } else if (sty_name.contains("medium")) { return 500; - } else if (sty_name.find("semibold") >= 0 || sty_name.find("demibold") >= 0) { + } else if (sty_name.contains("semibold") || sty_name.contains("demibold")) { return 600; - } else if (sty_name.find("bold") >= 0) { + } else if (sty_name.contains("bold")) { return 700; - } else if (sty_name.find("extrabold") >= 0 || sty_name.find("ultrabold") >= 0) { + } else if (sty_name.contains("extrabold") || sty_name.contains("ultrabold")) { return 800; - } else if (sty_name.find("black") >= 0 || sty_name.find("heavy") >= 0) { + } else if (sty_name.contains("black") || sty_name.contains("heavy")) { return 900; - } else if (sty_name.find("extrablack") >= 0 || sty_name.find("ultrablack") >= 0) { + } else if (sty_name.contains("extrablack") || sty_name.contains("ultrablack")) { return 950; } return 400; } _FORCE_INLINE_ int _font_get_stretch_by_name(const String &p_sty_name) const { String sty_name = p_sty_name.replace(" ", "").replace("-", ""); - if (sty_name.find("ultracondensed") >= 0) { + if (sty_name.contains("ultracondensed")) { return 50; - } else if (sty_name.find("extracondensed") >= 0) { + } else if (sty_name.contains("extracondensed")) { return 63; - } else if (sty_name.find("condensed") >= 0) { + } else if (sty_name.contains("condensed")) { return 75; - } else if (sty_name.find("semicondensed") >= 0) { + } else if (sty_name.contains("semicondensed")) { return 87; - } else if (sty_name.find("semiexpanded") >= 0) { + } else if (sty_name.contains("semiexpanded")) { return 113; - } else if (sty_name.find("expanded") >= 0) { + } else if (sty_name.contains("expanded")) { return 125; - } else if (sty_name.find("extraexpanded") >= 0) { + } else if (sty_name.contains("extraexpanded")) { return 150; - } else if (sty_name.find("ultraexpanded") >= 0) { + } else if (sty_name.contains("ultraexpanded")) { return 200; } return 100; } _FORCE_INLINE_ bool _is_ital_style(const String &p_sty_name) const { - return (p_sty_name.find("italic") >= 0) || (p_sty_name.find("oblique") >= 0); + return p_sty_name.contains("italic") || p_sty_name.contains("oblique"); } // Shaped text cache data. diff --git a/modules/text_server_fb/text_server_fb.h b/modules/text_server_fb/text_server_fb.h index 31370c7da74..9ad20c7b265 100644 --- a/modules/text_server_fb/text_server_fb.h +++ b/modules/text_server_fb/text_server_fb.h @@ -335,54 +335,54 @@ class TextServerFallback : public TextServerExtension { _FORCE_INLINE_ int _font_get_weight_by_name(const String &p_sty_name) const { String sty_name = p_sty_name.replace(" ", "").replace("-", ""); - if (sty_name.find("thin") >= 0 || sty_name.find("hairline") >= 0) { + if (sty_name.contains("thin") || sty_name.contains("hairline")) { return 100; - } else if (sty_name.find("extralight") >= 0 || sty_name.find("ultralight") >= 0) { + } else if (sty_name.contains("extralight") || sty_name.contains("ultralight")) { return 200; - } else if (sty_name.find("light") >= 0) { + } else if (sty_name.contains("light")) { return 300; - } else if (sty_name.find("semilight") >= 0) { + } else if (sty_name.contains("semilight")) { return 350; - } else if (sty_name.find("regular") >= 0) { + } else if (sty_name.contains("regular")) { return 400; - } else if (sty_name.find("medium") >= 0) { + } else if (sty_name.contains("medium")) { return 500; - } else if (sty_name.find("semibold") >= 0 || sty_name.find("demibold") >= 0) { + } else if (sty_name.contains("semibold") || sty_name.contains("demibold")) { return 600; - } else if (sty_name.find("bold") >= 0) { + } else if (sty_name.contains("bold")) { return 700; - } else if (sty_name.find("extrabold") >= 0 || sty_name.find("ultrabold") >= 0) { + } else if (sty_name.contains("extrabold") || sty_name.contains("ultrabold")) { return 800; - } else if (sty_name.find("black") >= 0 || sty_name.find("heavy") >= 0) { + } else if (sty_name.contains("black") || sty_name.contains("heavy")) { return 900; - } else if (sty_name.find("extrablack") >= 0 || sty_name.find("ultrablack") >= 0) { + } else if (sty_name.contains("extrablack") || sty_name.contains("ultrablack")) { return 950; } return 400; } _FORCE_INLINE_ int _font_get_stretch_by_name(const String &p_sty_name) const { String sty_name = p_sty_name.replace(" ", "").replace("-", ""); - if (sty_name.find("ultracondensed") >= 0) { + if (sty_name.contains("ultracondensed")) { return 50; - } else if (sty_name.find("extracondensed") >= 0) { + } else if (sty_name.contains("extracondensed")) { return 63; - } else if (sty_name.find("condensed") >= 0) { + } else if (sty_name.contains("condensed")) { return 75; - } else if (sty_name.find("semicondensed") >= 0) { + } else if (sty_name.contains("semicondensed")) { return 87; - } else if (sty_name.find("semiexpanded") >= 0) { + } else if (sty_name.contains("semiexpanded")) { return 113; - } else if (sty_name.find("expanded") >= 0) { + } else if (sty_name.contains("expanded")) { return 125; - } else if (sty_name.find("extraexpanded") >= 0) { + } else if (sty_name.contains("extraexpanded")) { return 150; - } else if (sty_name.find("ultraexpanded") >= 0) { + } else if (sty_name.contains("ultraexpanded")) { return 200; } return 100; } _FORCE_INLINE_ bool _is_ital_style(const String &p_sty_name) const { - return (p_sty_name.find("italic") >= 0) || (p_sty_name.find("oblique") >= 0); + return p_sty_name.contains("italic") || p_sty_name.contains("oblique"); } // Shaped text cache data. diff --git a/modules/upnp/upnp.cpp b/modules/upnp/upnp.cpp index 95453c1ecda..70f0ea346b1 100644 --- a/modules/upnp/upnp.cpp +++ b/modules/upnp/upnp.cpp @@ -37,10 +37,10 @@ bool UPNP::is_common_device(const String &dev) const { return dev.is_empty() || - dev.find("InternetGatewayDevice") >= 0 || - dev.find("WANIPConnection") >= 0 || - dev.find("WANPPPConnection") >= 0 || - dev.find("rootdevice") >= 0; + dev.contains("InternetGatewayDevice") || + dev.contains("WANIPConnection") || + dev.contains("WANPPPConnection") || + dev.contains("rootdevice"); } int UPNP::discover(int timeout, int ttl, const String &device_filter) { diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index 30d57cade58..eebef3f9691 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -816,11 +816,11 @@ Error EditorExportPlatformAndroid::copy_gradle_so(void *p_userdata, const Shared } bool EditorExportPlatformAndroid::_has_read_write_storage_permission(const Vector &p_permissions) { - return p_permissions.find("android.permission.READ_EXTERNAL_STORAGE") != -1 || p_permissions.find("android.permission.WRITE_EXTERNAL_STORAGE") != -1; + return p_permissions.has("android.permission.READ_EXTERNAL_STORAGE") || p_permissions.has("android.permission.WRITE_EXTERNAL_STORAGE"); } bool EditorExportPlatformAndroid::_has_manage_external_storage_permission(const Vector &p_permissions) { - return p_permissions.find("android.permission.MANAGE_EXTERNAL_STORAGE") != -1; + return p_permissions.has("android.permission.MANAGE_EXTERNAL_STORAGE"); } bool EditorExportPlatformAndroid::_uses_vulkan() { @@ -924,7 +924,7 @@ void EditorExportPlatformAndroid::_get_permissions(const Ref } } if (p_give_internet) { - if (r_permissions.find("android.permission.INTERNET") == -1) { + if (!r_permissions.has("android.permission.INTERNET")) { r_permissions.push_back("android.permission.INTERNET"); } } @@ -2716,7 +2716,7 @@ bool EditorExportPlatformAndroid::has_valid_project_configuration(const Refget("package/unique_name"); - if (package_name.find("$genname") >= 0 && !is_project_name_valid()) { + if (package_name.contains("$genname") && !is_project_name_valid()) { // Warning only, so don't override `valid`. err += vformat(TTR("The project name does not meet the requirement for the package name format and will be updated to \"%s\". Please explicitly specify the package name if needed."), get_valid_basename()); err += "\n"; diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index c60125c34e3..764959eef35 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -586,11 +586,11 @@ Vector OS_Android::get_system_font_path_for_text(const String &p_font_na } if (score > best_score) { best_score = score; - if (ret.find(root.path_join(E->get().filename)) < 0) { + if (!ret.has(root.path_join(E->get().filename))) { ret.insert(0, root.path_join(E->get().filename)); } } else if (score == best_score || E->get().script.is_empty()) { - if (ret.find(root.path_join(E->get().filename)) < 0) { + if (!ret.has(root.path_join(E->get().filename))) { ret.push_back(root.path_join(E->get().filename)); } } diff --git a/platform/ios/export/export_plugin.cpp b/platform/ios/export/export_plugin.cpp index c35c72d0934..6a452f08fa0 100644 --- a/platform/ios/export/export_plugin.cpp +++ b/platform/ios/export/export_plugin.cpp @@ -400,65 +400,65 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref &p_ str.parse_utf8((const char *)pfile.ptr(), pfile.size()); Vector lines = str.split("\n"); for (int i = 0; i < lines.size(); i++) { - if (lines[i].find("$binary") != -1) { + if (lines[i].contains("$binary")) { strnew += lines[i].replace("$binary", p_config.binary_name) + "\n"; - } else if (lines[i].find("$modules_buildfile") != -1) { + } else if (lines[i].contains("$modules_buildfile")) { strnew += lines[i].replace("$modules_buildfile", p_config.modules_buildfile) + "\n"; - } else if (lines[i].find("$modules_fileref") != -1) { + } else if (lines[i].contains("$modules_fileref")) { strnew += lines[i].replace("$modules_fileref", p_config.modules_fileref) + "\n"; - } else if (lines[i].find("$modules_buildphase") != -1) { + } else if (lines[i].contains("$modules_buildphase")) { strnew += lines[i].replace("$modules_buildphase", p_config.modules_buildphase) + "\n"; - } else if (lines[i].find("$modules_buildgrp") != -1) { + } else if (lines[i].contains("$modules_buildgrp")) { strnew += lines[i].replace("$modules_buildgrp", p_config.modules_buildgrp) + "\n"; - } else if (lines[i].find("$name") != -1) { + } else if (lines[i].contains("$name")) { strnew += lines[i].replace("$name", p_config.pkg_name) + "\n"; - } else if (lines[i].find("$bundle_identifier") != -1) { + } else if (lines[i].contains("$bundle_identifier")) { strnew += lines[i].replace("$bundle_identifier", p_preset->get("application/bundle_identifier")) + "\n"; - } else if (lines[i].find("$short_version") != -1) { + } else if (lines[i].contains("$short_version")) { strnew += lines[i].replace("$short_version", p_preset->get_version("application/short_version")) + "\n"; - } else if (lines[i].find("$version") != -1) { + } else if (lines[i].contains("$version")) { strnew += lines[i].replace("$version", p_preset->get_version("application/version")) + "\n"; - } else if (lines[i].find("$min_version") != -1) { + } else if (lines[i].contains("$min_version")) { strnew += lines[i].replace("$min_version", p_preset->get("application/min_ios_version")) + "\n"; - } else if (lines[i].find("$signature") != -1) { + } else if (lines[i].contains("$signature")) { strnew += lines[i].replace("$signature", p_preset->get("application/signature")) + "\n"; - } else if (lines[i].find("$team_id") != -1) { + } else if (lines[i].contains("$team_id")) { strnew += lines[i].replace("$team_id", p_preset->get("application/app_store_team_id")) + "\n"; - } else if (lines[i].find("$default_build_config") != -1) { + } else if (lines[i].contains("$default_build_config")) { strnew += lines[i].replace("$default_build_config", p_debug ? "Debug" : "Release") + "\n"; - } else if (lines[i].find("$export_method") != -1) { + } else if (lines[i].contains("$export_method")) { int export_method = p_preset->get(p_debug ? "application/export_method_debug" : "application/export_method_release"); strnew += lines[i].replace("$export_method", export_method_string[export_method]) + "\n"; - } else if (lines[i].find("$provisioning_profile_uuid_release") != -1) { + } else if (lines[i].contains("$provisioning_profile_uuid_release")) { strnew += lines[i].replace("$provisioning_profile_uuid_release", p_preset->get_or_env("application/provisioning_profile_uuid_release", ENV_IOS_PROFILE_UUID_RELEASE)) + "\n"; - } else if (lines[i].find("$provisioning_profile_uuid_debug") != -1) { + } else if (lines[i].contains("$provisioning_profile_uuid_debug")) { strnew += lines[i].replace("$provisioning_profile_uuid_debug", p_preset->get_or_env("application/provisioning_profile_uuid_debug", ENV_IOS_PROFILE_UUID_DEBUG)) + "\n"; - } else if (lines[i].find("$code_sign_style_debug") != -1) { + } else if (lines[i].contains("$code_sign_style_debug")) { if (dbg_manual) { strnew += lines[i].replace("$code_sign_style_debug", "Manual") + "\n"; } else { strnew += lines[i].replace("$code_sign_style_debug", "Automatic") + "\n"; } - } else if (lines[i].find("$code_sign_style_release") != -1) { + } else if (lines[i].contains("$code_sign_style_release")) { if (rel_manual) { strnew += lines[i].replace("$code_sign_style_release", "Manual") + "\n"; } else { strnew += lines[i].replace("$code_sign_style_release", "Automatic") + "\n"; } - } else if (lines[i].find("$provisioning_profile_uuid") != -1) { + } else if (lines[i].contains("$provisioning_profile_uuid")) { String uuid = p_debug ? p_preset->get_or_env("application/provisioning_profile_uuid_debug", ENV_IOS_PROFILE_UUID_DEBUG) : p_preset->get_or_env("application/provisioning_profile_uuid_release", ENV_IOS_PROFILE_UUID_RELEASE); strnew += lines[i].replace("$provisioning_profile_uuid", uuid) + "\n"; - } else if (lines[i].find("$code_sign_identity_debug") != -1) { + } else if (lines[i].contains("$code_sign_identity_debug")) { strnew += lines[i].replace("$code_sign_identity_debug", dbg_sign_id) + "\n"; - } else if (lines[i].find("$code_sign_identity_release") != -1) { + } else if (lines[i].contains("$code_sign_identity_release")) { strnew += lines[i].replace("$code_sign_identity_release", rel_sign_id) + "\n"; - } else if (lines[i].find("$additional_plist_content") != -1) { + } else if (lines[i].contains("$additional_plist_content")) { strnew += lines[i].replace("$additional_plist_content", p_config.plist_content) + "\n"; - } else if (lines[i].find("$godot_archs") != -1) { + } else if (lines[i].contains("$godot_archs")) { strnew += lines[i].replace("$godot_archs", p_config.architectures) + "\n"; - } else if (lines[i].find("$linker_flags") != -1) { + } else if (lines[i].contains("$linker_flags")) { strnew += lines[i].replace("$linker_flags", p_config.linker_flags) + "\n"; - } else if (lines[i].find("$targeted_device_family") != -1) { + } else if (lines[i].contains("$targeted_device_family")) { String xcode_value; switch ((int)p_preset->get("application/targeted_device_family")) { case 0: // iPhone @@ -472,16 +472,16 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref &p_ break; } strnew += lines[i].replace("$targeted_device_family", xcode_value) + "\n"; - } else if (lines[i].find("$cpp_code") != -1) { + } else if (lines[i].contains("$cpp_code")) { strnew += lines[i].replace("$cpp_code", p_config.cpp_code) + "\n"; - } else if (lines[i].find("$docs_in_place") != -1) { + } else if (lines[i].contains("$docs_in_place")) { strnew += lines[i].replace("$docs_in_place", ((bool)p_preset->get("user_data/accessible_from_files_app")) ? "" : "") + "\n"; - } else if (lines[i].find("$docs_sharing") != -1) { + } else if (lines[i].contains("$docs_sharing")) { strnew += lines[i].replace("$docs_sharing", ((bool)p_preset->get("user_data/accessible_from_itunes_sharing")) ? "" : "") + "\n"; - } else if (lines[i].find("$entitlements_push_notifications") != -1) { + } else if (lines[i].contains("$entitlements_push_notifications")) { bool is_on = p_preset->get("capabilities/push_notifications"); strnew += lines[i].replace("$entitlements_push_notifications", is_on ? "aps-environmentdevelopment" : "") + "\n"; - } else if (lines[i].find("$required_device_capabilities") != -1) { + } else if (lines[i].contains("$required_device_capabilities")) { String capabilities; // I've removed armv7 as we can run on 64bit only devices @@ -503,7 +503,7 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref &p_ } strnew += lines[i].replace("$required_device_capabilities", capabilities); - } else if (lines[i].find("$interface_orientations") != -1) { + } else if (lines[i].contains("$interface_orientations")) { String orientations; const DisplayServer::ScreenOrientation screen_orientation = DisplayServer::ScreenOrientation(int(GLOBAL_GET("display/window/handheld/orientation"))); @@ -541,35 +541,35 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref &p_ } strnew += lines[i].replace("$interface_orientations", orientations); - } else if (lines[i].find("$camera_usage_description") != -1) { + } else if (lines[i].contains("$camera_usage_description")) { String description = p_preset->get("privacy/camera_usage_description"); strnew += lines[i].replace("$camera_usage_description", description) + "\n"; - } else if (lines[i].find("$microphone_usage_description") != -1) { + } else if (lines[i].contains("$microphone_usage_description")) { String description = p_preset->get("privacy/microphone_usage_description"); strnew += lines[i].replace("$microphone_usage_description", description) + "\n"; - } else if (lines[i].find("$photolibrary_usage_description") != -1) { + } else if (lines[i].contains("$photolibrary_usage_description")) { String description = p_preset->get("privacy/photolibrary_usage_description"); strnew += lines[i].replace("$photolibrary_usage_description", description) + "\n"; - } else if (lines[i].find("$plist_launch_screen_name") != -1) { + } else if (lines[i].contains("$plist_launch_screen_name")) { String value = "UILaunchStoryboardName\nLaunch Screen"; strnew += lines[i].replace("$plist_launch_screen_name", value) + "\n"; - } else if (lines[i].find("$pbx_launch_screen_file_reference") != -1) { + } else if (lines[i].contains("$pbx_launch_screen_file_reference")) { String value = "90DD2D9D24B36E8000717FE1 = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = \"Launch Screen.storyboard\"; sourceTree = \"\"; };"; strnew += lines[i].replace("$pbx_launch_screen_file_reference", value) + "\n"; - } else if (lines[i].find("$pbx_launch_screen_copy_files") != -1) { + } else if (lines[i].contains("$pbx_launch_screen_copy_files")) { String value = "90DD2D9D24B36E8000717FE1 /* Launch Screen.storyboard */,"; strnew += lines[i].replace("$pbx_launch_screen_copy_files", value) + "\n"; - } else if (lines[i].find("$pbx_launch_screen_build_phase") != -1) { + } else if (lines[i].contains("$pbx_launch_screen_build_phase")) { String value = "90DD2D9E24B36E8000717FE1 /* Launch Screen.storyboard in Resources */,"; strnew += lines[i].replace("$pbx_launch_screen_build_phase", value) + "\n"; - } else if (lines[i].find("$pbx_launch_screen_build_reference") != -1) { + } else if (lines[i].contains("$pbx_launch_screen_build_reference")) { String value = "90DD2D9E24B36E8000717FE1 /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 90DD2D9D24B36E8000717FE1 /* Launch Screen.storyboard */; };"; strnew += lines[i].replace("$pbx_launch_screen_build_reference", value) + "\n"; #ifndef DISABLE_DEPRECATED - } else if (lines[i].find("$pbx_launch_image_usage_setting") != -1) { + } else if (lines[i].contains("$pbx_launch_image_usage_setting")) { strnew += lines[i].replace("$pbx_launch_image_usage_setting", "") + "\n"; #endif - } else if (lines[i].find("$launch_screen_image_mode") != -1) { + } else if (lines[i].contains("$launch_screen_image_mode")) { int image_scale_mode = p_preset->get("storyboard/image_scale_mode"); String value; @@ -586,7 +586,7 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref &p_ } strnew += lines[i].replace("$launch_screen_image_mode", value) + "\n"; - } else if (lines[i].find("$launch_screen_background_color") != -1) { + } else if (lines[i].contains("$launch_screen_background_color")) { bool use_custom = p_preset->get("storyboard/use_custom_bg_color"); Color color = use_custom ? p_preset->get("storyboard/custom_bg_color") : GLOBAL_GET("application/boot_splash/bg_color"); const String value_format = "red=\"$red\" green=\"$green\" blue=\"$blue\" alpha=\"$alpha\""; @@ -599,7 +599,7 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref &p_ String value = value_format.format(value_dictionary, "$_"); strnew += lines[i].replace("$launch_screen_background_color", value) + "\n"; - } else if (lines[i].find("$pbx_locale_file_reference") != -1) { + } else if (lines[i].contains("$pbx_locale_file_reference")) { String locale_files; Vector translations = GLOBAL_GET("internationalization/locale/translations"); if (translations.size() > 0) { @@ -618,7 +618,7 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref &p_ } } strnew += lines[i].replace("$pbx_locale_file_reference", locale_files); - } else if (lines[i].find("$pbx_locale_build_reference") != -1) { + } else if (lines[i].contains("$pbx_locale_build_reference")) { String locale_files; Vector translations = GLOBAL_GET("internationalization/locale/translations"); if (translations.size() > 0) { @@ -637,10 +637,10 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref &p_ } } strnew += lines[i].replace("$pbx_locale_build_reference", locale_files); - } else if (lines[i].find("$swift_runtime_migration") != -1) { + } else if (lines[i].contains("$swift_runtime_migration")) { String value = !p_config.use_swift_runtime ? "" : "LastSwiftMigration = 1250;"; strnew += lines[i].replace("$swift_runtime_migration", value) + "\n"; - } else if (lines[i].find("$swift_runtime_build_settings") != -1) { + } else if (lines[i].contains("$swift_runtime_build_settings")) { String value = !p_config.use_swift_runtime ? "" : R"( CLANG_ENABLE_MODULES = YES; SWIFT_OBJC_BRIDGING_HEADER = "$binary/dummy.h"; @@ -648,25 +648,25 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref &p_ )"; value = value.replace("$binary", p_config.binary_name); strnew += lines[i].replace("$swift_runtime_build_settings", value) + "\n"; - } else if (lines[i].find("$swift_runtime_fileref") != -1) { + } else if (lines[i].contains("$swift_runtime_fileref")) { String value = !p_config.use_swift_runtime ? "" : R"( 90B4C2AA2680BC560039117A /* dummy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "dummy.h"; sourceTree = ""; }; 90B4C2B52680C7E90039117A /* dummy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "dummy.swift"; sourceTree = ""; }; )"; strnew += lines[i].replace("$swift_runtime_fileref", value) + "\n"; - } else if (lines[i].find("$swift_runtime_binary_files") != -1) { + } else if (lines[i].contains("$swift_runtime_binary_files")) { String value = !p_config.use_swift_runtime ? "" : R"( 90B4C2AA2680BC560039117A /* dummy.h */, 90B4C2B52680C7E90039117A /* dummy.swift */, )"; strnew += lines[i].replace("$swift_runtime_binary_files", value) + "\n"; - } else if (lines[i].find("$swift_runtime_buildfile") != -1) { + } else if (lines[i].contains("$swift_runtime_buildfile")) { String value = !p_config.use_swift_runtime ? "" : "90B4C2B62680C7E90039117A /* dummy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90B4C2B52680C7E90039117A /* dummy.swift */; };"; strnew += lines[i].replace("$swift_runtime_buildfile", value) + "\n"; - } else if (lines[i].find("$swift_runtime_build_phase") != -1) { + } else if (lines[i].contains("$swift_runtime_build_phase")) { String value = !p_config.use_swift_runtime ? "" : "90B4C2B62680C7E90039117A /* dummy.swift */,"; strnew += lines[i].replace("$swift_runtime_build_phase", value) + "\n"; - } else if (lines[i].find("$priv_collection") != -1) { + } else if (lines[i].contains("$priv_collection")) { bool section_opened = false; for (uint64_t j = 0; j < sizeof(data_collect_type_info) / sizeof(data_collect_type_info[0]); ++j) { bool data_collected = p_preset->get(vformat("privacy/collected_data/%s/collected", data_collect_type_info[j].prop_name)); @@ -710,7 +710,7 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref &p_ if (section_opened) { strnew += "\t\n"; } - } else if (lines[i].find("$priv_tracking") != -1) { + } else if (lines[i].contains("$priv_tracking")) { bool tracking = p_preset->get("privacy/tracking_enabled"); strnew += "\tNSPrivacyTracking\n"; if (tracking) { @@ -727,7 +727,7 @@ void EditorExportPlatformIOS::_fix_config_file(const Ref &p_ } strnew += "\t\n"; } - } else if (lines[i].find("$priv_api_types") != -1) { + } else if (lines[i].contains("$priv_api_types")) { strnew += "\t\n"; for (uint64_t j = 0; j < sizeof(api_info) / sizeof(api_info[0]); ++j) { int api_access = p_preset->get(vformat("privacy/%s_access_reasons", api_info[j].prop_name)); diff --git a/platform/linuxbsd/joypad_linux.cpp b/platform/linuxbsd/joypad_linux.cpp index 827c5677855..6e546c4531b 100644 --- a/platform/linuxbsd/joypad_linux.cpp +++ b/platform/linuxbsd/joypad_linux.cpp @@ -175,7 +175,7 @@ void JoypadLinux::enumerate_joypads(udev *p_udev) { if (devnode) { String devnode_str = devnode; - if (devnode_str.find(ignore_str) == -1) { + if (!devnode_str.contains(ignore_str)) { open_joypad(devnode); } } @@ -214,7 +214,7 @@ void JoypadLinux::monitor_joypads(udev *p_udev) { const char *devnode = udev_device_get_devnode(dev); if (devnode) { String devnode_str = devnode; - if (devnode_str.find(ignore_str) == -1) { + if (!devnode_str.contains(ignore_str)) { if (action == "add") { open_joypad(devnode); } else if (String(action) == "remove") { @@ -244,7 +244,7 @@ void JoypadLinux::monitor_joypads() { continue; } sprintf(fname, "/dev/input/%.*s", 16, current->d_name); - if (attached_devices.find(fname) == -1) { + if (!attached_devices.has(fname)) { open_joypad(fname); } } diff --git a/platform/linuxbsd/os_linuxbsd.cpp b/platform/linuxbsd/os_linuxbsd.cpp index 68b4cd7f5aa..6355562febd 100644 --- a/platform/linuxbsd/os_linuxbsd.cpp +++ b/platform/linuxbsd/os_linuxbsd.cpp @@ -184,7 +184,7 @@ String OS_LinuxBSD::get_processor_name() const { while (!f->eof_reached()) { const String line = f->get_line(); - if (line.find("model name") != -1) { + if (line.contains("model name")) { return line.split(":")[1].strip_edges(); } } @@ -269,7 +269,7 @@ String OS_LinuxBSD::get_systemd_os_release_info_value(const String &key) const { if (f.is_valid()) { while (!f->eof_reached()) { const String line = f->get_line(); - if (line.find(key) != -1) { + if (line.contains(key)) { String value = line.split("=")[1].strip_edges(); value = value.trim_prefix("\""); return value.trim_suffix("\""); diff --git a/platform/macos/export/export_plugin.cpp b/platform/macos/export/export_plugin.cpp index 5f52d33318f..96d64ef2090 100644 --- a/platform/macos/export/export_plugin.cpp +++ b/platform/macos/export/export_plugin.cpp @@ -650,42 +650,42 @@ void EditorExportPlatformMacOS::_fix_plist(const Ref &p_pres str.parse_utf8((const char *)plist.ptr(), plist.size()); Vector lines = str.split("\n"); for (int i = 0; i < lines.size(); i++) { - if (lines[i].find("$binary") != -1) { + if (lines[i].contains("$binary")) { strnew += lines[i].replace("$binary", p_binary) + "\n"; - } else if (lines[i].find("$name") != -1) { + } else if (lines[i].contains("$name")) { strnew += lines[i].replace("$name", GLOBAL_GET("application/config/name")) + "\n"; - } else if (lines[i].find("$bundle_identifier") != -1) { + } else if (lines[i].contains("$bundle_identifier")) { strnew += lines[i].replace("$bundle_identifier", p_preset->get("application/bundle_identifier")) + "\n"; - } else if (lines[i].find("$short_version") != -1) { + } else if (lines[i].contains("$short_version")) { strnew += lines[i].replace("$short_version", p_preset->get_version("application/short_version")) + "\n"; - } else if (lines[i].find("$version") != -1) { + } else if (lines[i].contains("$version")) { strnew += lines[i].replace("$version", p_preset->get_version("application/version")) + "\n"; - } else if (lines[i].find("$signature") != -1) { + } else if (lines[i].contains("$signature")) { strnew += lines[i].replace("$signature", p_preset->get("application/signature")) + "\n"; - } else if (lines[i].find("$app_category") != -1) { + } else if (lines[i].contains("$app_category")) { String cat = p_preset->get("application/app_category"); strnew += lines[i].replace("$app_category", cat.to_lower()) + "\n"; - } else if (lines[i].find("$copyright") != -1) { + } else if (lines[i].contains("$copyright")) { strnew += lines[i].replace("$copyright", p_preset->get("application/copyright")) + "\n"; - } else if (lines[i].find("$min_version") != -1) { + } else if (lines[i].contains("$min_version")) { strnew += lines[i].replace("$min_version", p_preset->get("application/min_macos_version")) + "\n"; - } else if (lines[i].find("$highres") != -1) { + } else if (lines[i].contains("$highres")) { strnew += lines[i].replace("$highres", p_preset->get("display/high_res") ? "\t" : "\t") + "\n"; - } else if (lines[i].find("$additional_plist_content") != -1) { + } else if (lines[i].contains("$additional_plist_content")) { strnew += lines[i].replace("$additional_plist_content", p_preset->get("application/additional_plist_content")) + "\n"; - } else if (lines[i].find("$platfbuild") != -1) { + } else if (lines[i].contains("$platfbuild")) { strnew += lines[i].replace("$platfbuild", p_preset->get("xcode/platform_build")) + "\n"; - } else if (lines[i].find("$sdkver") != -1) { + } else if (lines[i].contains("$sdkver")) { strnew += lines[i].replace("$sdkver", p_preset->get("xcode/sdk_version")) + "\n"; - } else if (lines[i].find("$sdkname") != -1) { + } else if (lines[i].contains("$sdkname")) { strnew += lines[i].replace("$sdkname", p_preset->get("xcode/sdk_name")) + "\n"; - } else if (lines[i].find("$sdkbuild") != -1) { + } else if (lines[i].contains("$sdkbuild")) { strnew += lines[i].replace("$sdkbuild", p_preset->get("xcode/sdk_build")) + "\n"; - } else if (lines[i].find("$xcodever") != -1) { + } else if (lines[i].contains("$xcodever")) { strnew += lines[i].replace("$xcodever", p_preset->get("xcode/xcode_version")) + "\n"; - } else if (lines[i].find("$xcodebuild") != -1) { + } else if (lines[i].contains("$xcodebuild")) { strnew += lines[i].replace("$xcodebuild", p_preset->get("xcode/xcode_build")) + "\n"; - } else if (lines[i].find("$usage_descriptions") != -1) { + } else if (lines[i].contains("$usage_descriptions")) { String descriptions; if (!((String)p_preset->get("privacy/microphone_usage_description")).is_empty()) { descriptions += "\tNSMicrophoneUsageDescription\n"; @@ -1081,7 +1081,7 @@ Error EditorExportPlatformMacOS::_code_sign_directory(const Ref -1) { + if (extensions_to_sign.has(current_file.get_extension())) { int ftype = MachO::get_filetype(current_file_path); Error code_sign_error{ _code_sign(p_preset, current_file_path, (ftype == 2 || ftype == 5) ? p_helper_ent_path : p_ent_path, false, (ftype == 2 || ftype == 5)) }; if (code_sign_error != OK) { @@ -1202,7 +1202,7 @@ Error EditorExportPlatformMacOS::_copy_and_sign_files(Ref &dir_access // If it is a directory, find and sign all dynamic libraries. err = _code_sign_directory(p_preset, p_in_app_path, p_ent_path, p_helper_ent_path, p_should_error_on_non_code_sign); } else { - if (extensions_to_sign.find(p_in_app_path.get_extension()) > -1) { + if (extensions_to_sign.has(p_in_app_path.get_extension())) { int ftype = MachO::get_filetype(p_in_app_path); err = _code_sign(p_preset, p_in_app_path, (ftype == 2 || ftype == 5) ? p_helper_ent_path : p_ent_path, false, (ftype == 2 || ftype == 5)); } @@ -1260,7 +1260,7 @@ Error EditorExportPlatformMacOS::_create_pkg(const Ref &p_pr } print_verbose("productbuild returned: " + str); - if (str.find("productbuild: error:") != -1) { + if (str.contains("productbuild: error:")) { add_message(EXPORT_MESSAGE_ERROR, TTR("PKG Creation"), TTR("`productbuild` failed.")); return FAILED; } @@ -1292,8 +1292,8 @@ Error EditorExportPlatformMacOS::_create_dmg(const String &p_dmg_path, const Str } print_verbose("hdiutil returned: " + str); - if (str.find("create failed") != -1) { - if (str.find("File exists") != -1) { + if (str.contains("create failed")) { + if (str.contains("File exists")) { add_message(EXPORT_MESSAGE_ERROR, TTR("DMG Creation"), TTR("`hdiutil create` failed - file exists.")); } else { add_message(EXPORT_MESSAGE_ERROR, TTR("DMG Creation"), TTR("`hdiutil create` failed.")); diff --git a/platform/windows/export/export_plugin.cpp b/platform/windows/export/export_plugin.cpp index a3c86611a47..6ce9d27dc5a 100644 --- a/platform/windows/export/export_plugin.cpp +++ b/platform/windows/export/export_plugin.cpp @@ -347,7 +347,7 @@ String EditorExportPlatformWindows::get_export_option_warning(const EditorExport PackedStringArray version_array = file_version.split(".", false); if (version_array.size() != 4 || !version_array[0].is_valid_int() || !version_array[1].is_valid_int() || !version_array[2].is_valid_int() || - !version_array[3].is_valid_int() || file_version.find("-") > -1) { + !version_array[3].is_valid_int() || file_version.contains("-")) { return TTR("Invalid file version."); } } @@ -357,7 +357,7 @@ String EditorExportPlatformWindows::get_export_option_warning(const EditorExport PackedStringArray version_array = product_version.split(".", false); if (version_array.size() != 4 || !version_array[0].is_valid_int() || !version_array[1].is_valid_int() || !version_array[2].is_valid_int() || - !version_array[3].is_valid_int() || product_version.find("-") > -1) { + !version_array[3].is_valid_int() || product_version.contains("-")) { return TTR("Invalid product version."); } } @@ -569,13 +569,13 @@ Error EditorExportPlatformWindows::_rcedit_add_data(const Ref Windows > rcedit), or disable \"Application > Modify Resources\" in the export preset.")); return err; } print_line("rcedit (" + p_path + "): " + str); - if (str.find("Fatal error") != -1) { + if (str.contains("Fatal error")) { add_message(EXPORT_MESSAGE_WARNING, TTR("Resources Modification"), vformat(TTR("rcedit failed to modify executable: %s."), str)); return FAILED; } @@ -718,7 +718,7 @@ Error EditorExportPlatformWindows::_code_sign(const Ref &p_p String str; Error err = OS::get_singleton()->execute(signtool_path, args, &str, nullptr, true); - if (err != OK || (str.find("not found") != -1) || (str.find("not recognized") != -1)) { + if (err != OK || str.contains("not found") || str.contains("not recognized")) { #ifdef WINDOWS_ENABLED add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), TTR("Could not start signtool executable. Configure signtool path in the Editor Settings (Export > Windows > signtool), or disable \"Codesign\" in the export preset.")); #else @@ -729,9 +729,9 @@ Error EditorExportPlatformWindows::_code_sign(const Ref &p_p print_line("codesign (" + p_path + "): " + str); #ifndef WINDOWS_ENABLED - if (str.find("SignTool Error") != -1) { + if (str.contains("SignTool Error")) { #else - if (str.find("Failed") != -1) { + if (str.contains("Failed")) { #endif add_message(EXPORT_MESSAGE_WARNING, TTR("Code Signing"), vformat(TTR("Signtool failed to sign executable: %s."), str)); return FAILED; diff --git a/scene/3d/skeleton_3d.cpp b/scene/3d/skeleton_3d.cpp index 2ddccb02533..72b5b53b19d 100644 --- a/scene/3d/skeleton_3d.cpp +++ b/scene/3d/skeleton_3d.cpp @@ -253,7 +253,7 @@ void Skeleton3D::_update_process_order() { int parent_bone_idx = bonesptr[i].parent; // Check to see if this node is already added to the parent. - if (bonesptr[parent_bone_idx].child_bones.find(i) < 0) { + if (!bonesptr[parent_bone_idx].child_bones.has(i)) { // Add the child node. bonesptr[parent_bone_idx].child_bones.push_back(i); } else { diff --git a/scene/gui/texture_progress_bar.cpp b/scene/gui/texture_progress_bar.cpp index bbe5ddf1c3e..dc48945d9b5 100644 --- a/scene/gui/texture_progress_bar.cpp +++ b/scene/gui/texture_progress_bar.cpp @@ -526,7 +526,7 @@ void TextureProgressBar::_notification(int p_what) { Vector points; for (const float &f : pts) { Point2 uv = unit_val_to_uv(f); - if (uvs.find(uv) >= 0) { + if (uvs.has(uv)) { continue; } points.push_back(progress_offset + Point2(uv.x * s.x, uv.y * s.y)); diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index 73f3009fd1f..8b5e438aea6 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -1880,7 +1880,7 @@ void ArrayMesh::set_blend_shape_name(int p_index, const StringName &p_name) { do { shape_name = String(p_name) + " " + itos(count); count++; - } while (blend_shapes.find(shape_name) != -1); + } while (blend_shapes.has(shape_name)); } blend_shapes.write[p_index] = shape_name; diff --git a/servers/audio/audio_stream.cpp b/servers/audio/audio_stream.cpp index b5333d91c66..051ed596329 100644 --- a/servers/audio/audio_stream.cpp +++ b/servers/audio/audio_stream.cpp @@ -618,7 +618,7 @@ Ref AudioStreamRandomizer::instance_playback_sequential() { if (entry.stream.is_null()) { continue; } - if (local_pool.find(entry.stream) != -1) { + if (local_pool.has(entry.stream)) { WARN_PRINT("Duplicate stream in sequential playback pool"); continue; } diff --git a/servers/rendering/rendering_device.cpp b/servers/rendering/rendering_device.cpp index 1ee5362f2ce..31fc51efaa9 100644 --- a/servers/rendering/rendering_device.cpp +++ b/servers/rendering/rendering_device.cpp @@ -671,9 +671,9 @@ RID RenderingDevice::texture_create(const TextureFormat &p_format, const Texture TextureFormat format = p_format; if (format.shareable_formats.size()) { - ERR_FAIL_COND_V_MSG(format.shareable_formats.find(format.format) == -1, RID(), + ERR_FAIL_COND_V_MSG(!format.shareable_formats.has(format.format), RID(), "If supplied a list of shareable formats, the current format must be present in the list"); - ERR_FAIL_COND_V_MSG(p_view.format_override != DATA_FORMAT_MAX && format.shareable_formats.find(p_view.format_override) == -1, RID(), + ERR_FAIL_COND_V_MSG(p_view.format_override != DATA_FORMAT_MAX && !format.shareable_formats.has(p_view.format_override), RID(), "If supplied a list of shareable formats, the current view format override must be present in the list"); } @@ -854,7 +854,7 @@ RID RenderingDevice::texture_create_shared(const TextureView &p_view, RID p_with } else { ERR_FAIL_INDEX_V(p_view.format_override, DATA_FORMAT_MAX, RID()); - ERR_FAIL_COND_V_MSG(texture.allowed_shared_formats.find(p_view.format_override) == -1, RID(), + ERR_FAIL_COND_V_MSG(!texture.allowed_shared_formats.has(p_view.format_override), RID(), "Format override is not in the list of allowed shareable formats for original texture."); tv.format = p_view.format_override; } @@ -984,7 +984,7 @@ RID RenderingDevice::texture_create_shared_from_slice(const TextureView &p_view, } else { ERR_FAIL_INDEX_V(p_view.format_override, DATA_FORMAT_MAX, RID()); - ERR_FAIL_COND_V_MSG(texture.allowed_shared_formats.find(p_view.format_override) == -1, RID(), + ERR_FAIL_COND_V_MSG(!texture.allowed_shared_formats.has(p_view.format_override), RID(), "Format override is not in the list of allowed shareable formats for original texture."); tv.format = p_view.format_override; } diff --git a/tests/core/object/test_class_db.h b/tests/core/object/test_class_db.h index fb62d0f0564..381d759e5bc 100644 --- a/tests/core/object/test_class_db.h +++ b/tests/core/object/test_class_db.h @@ -195,12 +195,12 @@ struct Context { } bool has_type(const TypeReference &p_type_ref) const { - if (builtin_types.find(p_type_ref.name) >= 0) { + if (builtin_types.has(p_type_ref.name)) { return true; } if (p_type_ref.is_enum) { - if (enum_types.find(p_type_ref.name) >= 0) { + if (enum_types.has(p_type_ref.name)) { return true; } @@ -355,7 +355,7 @@ void validate_property(const Context &p_context, const ExposedClass &p_class, co const ArgumentData &idx_arg = getter->arguments.front()->get(); if (idx_arg.type.name != p_context.names_cache.int_type) { // If not an int, it can be an enum - TEST_COND(p_context.enum_types.find(idx_arg.type.name) < 0, + TEST_COND(!p_context.enum_types.has(idx_arg.type.name), "Invalid type '", idx_arg.type.name, "' for index argument of property getter: '", p_class.name, ".", String(p_prop.name), "'."); } } @@ -367,7 +367,7 @@ void validate_property(const Context &p_context, const ExposedClass &p_class, co if (idx_arg.type.name != p_context.names_cache.int_type) { // Assume the index parameter is an enum // If not an int, it can be an enum - TEST_COND(p_context.enum_types.find(idx_arg.type.name) < 0, + TEST_COND(!p_context.enum_types.has(idx_arg.type.name), "Invalid type '", idx_arg.type.name, "' for index argument of property setter: '", p_class.name, ".", String(p_prop.name), "'."); } } @@ -736,7 +736,7 @@ void add_exposed_classes(Context &r_context) { for (const StringName &E : K.value.constants) { const StringName &constant_name = E; - TEST_FAIL_COND(String(constant_name).find("::") != -1, + TEST_FAIL_COND(String(constant_name).contains("::"), "Enum constant contains '::', check bindings to remove the scope: '", String(class_name), ".", String(enum_.name), ".", String(constant_name), "'."); int64_t *value = class_info->constant_map.getptr(constant_name); @@ -758,7 +758,7 @@ void add_exposed_classes(Context &r_context) { for (const String &E : constants) { const String &constant_name = E; - TEST_FAIL_COND(constant_name.find("::") != -1, + TEST_FAIL_COND(constant_name.contains("::"), "Constant contains '::', check bindings to remove the scope: '", String(class_name), ".", constant_name, "'."); int64_t *value = class_info->constant_map.getptr(StringName(E)); diff --git a/tests/test_main.cpp b/tests/test_main.cpp index 69d8113e647..41fc21b4695 100644 --- a/tests/test_main.cpp +++ b/tests/test_main.cpp @@ -242,7 +242,7 @@ struct GodotTestCaseListener : public doctest::IReporter { String name = String(p_in.m_name); String suite_name = String(p_in.m_test_suite); - if (name.find("[SceneTree]") != -1 || name.find("[Editor]") != -1) { + if (name.contains("[SceneTree]") || name.contains("[Editor]")) { memnew(MessageQueue); memnew(Input); @@ -291,7 +291,7 @@ struct GodotTestCaseListener : public doctest::IReporter { } #ifdef TOOLS_ENABLED - if (name.find("[Editor]") != -1) { + if (name.contains("[Editor]")) { Engine::get_singleton()->set_editor_hint(true); EditorPaths::create(); EditorSettings::create(); @@ -301,7 +301,7 @@ struct GodotTestCaseListener : public doctest::IReporter { return; } - if (name.find("Audio") != -1) { + if (name.contains("Audio")) { // The last driver index should always be the dummy driver. int dummy_idx = AudioDriverManager::get_driver_count() - 1; AudioDriverManager::initialize(dummy_idx); @@ -311,7 +311,7 @@ struct GodotTestCaseListener : public doctest::IReporter { } #ifndef _3D_DISABLED - if (suite_name.find("[Navigation]") != -1 && navigation_server_2d == nullptr && navigation_server_3d == nullptr) { + if (suite_name.contains("[Navigation]") && navigation_server_2d == nullptr && navigation_server_3d == nullptr) { ERR_PRINT_OFF; navigation_server_3d = NavigationServer3DManager::new_default_server(); navigation_server_2d = NavigationServer2DManager::new_default_server();