diff --git a/editor/dependency_editor.cpp b/editor/dependency_editor.cpp index 8ba5811ffa6..147e9f7b88c 100644 --- a/editor/dependency_editor.cpp +++ b/editor/dependency_editor.cpp @@ -467,17 +467,18 @@ void DependencyRemoveDialog::_find_localization_remaps_of_removed_files(Vector remap_keys; + remaps.get_key_list(&remap_keys); + for (const Variant &remap_key : remap_keys) { + PackedStringArray remapped_files = remaps[remap_key]; + for (int j = 0; j < remapped_files.size(); j++) { + int splitter_pos = remapped_files[j].rfind(":"); + String res_path = remapped_files[j].substr(0, splitter_pos); if (res_path == path) { - String locale_name = remapped_files[k].substr(splitter_pos + 1); + String locale_name = remapped_files[j].substr(splitter_pos + 1); RemovedDependency dep; - dep.file = vformat(TTR("Localization remap for path '%s' and locale '%s'."), remap_keys[j], locale_name); + dep.file = vformat(TTR("Localization remap for path '%s' and locale '%s'."), remap_key, locale_name); dep.file_type = ""; dep.dependency = path; dep.dependency_folder = files.value; diff --git a/editor/editor_command_palette.cpp b/editor/editor_command_palette.cpp index f40307712d4..496ec44aaac 100644 --- a/editor/editor_command_palette.cpp +++ b/editor/editor_command_palette.cpp @@ -293,9 +293,9 @@ void EditorCommandPalette::register_shortcuts_as_command() { // Load command use history. Dictionary command_history = EditorSettings::get_singleton()->get_project_metadata("command_palette", "command_history", Dictionary()); - Array history_entries = command_history.keys(); - for (int i = 0; i < history_entries.size(); i++) { - const String &history_key = history_entries[i]; + List history_entries; + command_history.get_key_list(&history_entries); + for (const String history_key : history_entries) { if (commands.has(history_key)) { commands[history_key].last_used = command_history[history_key]; } diff --git a/editor/export/editor_export_preset.cpp b/editor/export/editor_export_preset.cpp index 1ca72348e20..535fc6ce994 100644 --- a/editor/export/editor_export_preset.cpp +++ b/editor/export/editor_export_preset.cpp @@ -187,9 +187,9 @@ void EditorExportPreset::update_value_overrides() { Dictionary plugin_overrides = export_plugins[i]->_get_export_options_overrides(platform); if (!plugin_overrides.is_empty()) { - Array keys = plugin_overrides.keys(); - for (int x = 0; x < keys.size(); x++) { - StringName key = keys[x]; + List keys; + plugin_overrides.get_key_list(&keys); + for (const StringName key : keys) { Variant value = plugin_overrides[key]; if (new_value_overrides.has(key) && new_value_overrides[key] != value) { WARN_PRINT_ED(vformat("Editor export plugin '%s' overrides pre-existing export option override '%s' with new value.", export_plugins[i]->get_name(), key)); diff --git a/editor/import/3d/resource_importer_scene.cpp b/editor/import/3d/resource_importer_scene.cpp index cb348f713c1..aeac399dcd5 100644 --- a/editor/import/3d/resource_importer_scene.cpp +++ b/editor/import/3d/resource_importer_scene.cpp @@ -2869,9 +2869,10 @@ Node *ResourceImporterScene::pre_import(const String &p_source_file, const HashM } Error ResourceImporterScene::_check_resource_save_paths(const Dictionary &p_data) { - Array keys = p_data.keys(); - for (int i = 0; i < keys.size(); i++) { - const Dictionary &settings = p_data[keys[i]]; + List keys; + p_data.get_key_list(&keys); + for (const Variant &key : keys) { + const Dictionary &settings = p_data[key]; if (bool(settings.get("save_to_file/enabled", false)) && settings.has("save_to_file/path")) { const String &save_path = settings["save_to_file/path"]; diff --git a/editor/localization_editor.cpp b/editor/localization_editor.cpp index 921467ccbc3..8c75da2f2a0 100644 --- a/editor/localization_editor.cpp +++ b/editor/localization_editor.cpp @@ -435,9 +435,10 @@ void LocalizationEditor::_filesystem_files_moved(const String &p_old_file, const } // Check for the Array elements of the values. - Array remap_keys = remaps.keys(); - for (int i = 0; i < remap_keys.size(); i++) { - PackedStringArray remapped_files = remaps[remap_keys[i]]; + List remap_keys; + remaps.get_key_list(&remap_keys); + for (const Variant &remap_key : remap_keys) { + PackedStringArray remapped_files = remaps[remap_key]; bool remapped_files_updated = false; for (int j = 0; j < remapped_files.size(); j++) { @@ -451,12 +452,12 @@ void LocalizationEditor::_filesystem_files_moved(const String &p_old_file, const remapped_files.remove_at(j + 1); remaps_changed = true; remapped_files_updated = true; - print_verbose(vformat("Changed remap value \"%s\" to \"%s\" of key \"%s\" due to a moved file.", res_path + ":" + locale_name, remapped_files[j], remap_keys[i])); + print_verbose(vformat("Changed remap value \"%s\" to \"%s\" of key \"%s\" due to a moved file.", res_path + ":" + locale_name, remapped_files[j], remap_key)); } } if (remapped_files_updated) { - remaps[remap_keys[i]] = remapped_files; + remaps[remap_key] = remapped_files; } } diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index dc86acd884d..df3a86f5015 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -7780,7 +7780,8 @@ void Node3DEditor::_snap_selected_nodes_to_floor() { PhysicsDirectSpaceState3D *ss = get_tree()->get_root()->get_world_3d()->get_direct_space_state(); PhysicsDirectSpaceState3D::RayResult result; - Array keys = snap_data.keys(); + List keys; + snap_data.get_key_list(&keys); // The maximum height an object can travel to be snapped const float max_snap_height = 500.0; @@ -7791,8 +7792,8 @@ void Node3DEditor::_snap_selected_nodes_to_floor() { if (keys.size()) { // For snapping to be performed, there must be solid geometry under at least one of the selected nodes. // We need to check this before snapping to register the undo/redo action only if needed. - for (int i = 0; i < keys.size(); i++) { - Node *node = Object::cast_to(keys[i]); + for (const Variant &key : keys) { + Node *node = Object::cast_to(key); Node3D *sp = Object::cast_to(node); Dictionary d = snap_data[node]; Vector3 from = d["from"]; @@ -7814,8 +7815,8 @@ void Node3DEditor::_snap_selected_nodes_to_floor() { undo_redo->create_action(TTR("Snap Nodes to Floor")); // Perform snapping if at least one node can be snapped - for (int i = 0; i < keys.size(); i++) { - Node *node = Object::cast_to(keys[i]); + for (const Variant &key : keys) { + Node *node = Object::cast_to(key); Node3D *sp = Object::cast_to(node); Dictionary d = snap_data[node]; Vector3 from = d["from"]; diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index f98a30ebb3d..116818b68b3 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -2128,12 +2128,11 @@ void VisualShaderEditor::_update_nodes() { } } - Array keys = added.keys(); + List keys; + added.get_key_list(&keys); keys.sort(); - for (int i = 0; i < keys.size(); i++) { - const Variant &key = keys.get(i); - + for (const Variant &key : keys) { const Dictionary &value = (Dictionary)added[key]; add_custom_type(value["name"], value["type"], value["script"], value["description"], value["return_icon_type"], value["category"], value["highend"]); diff --git a/modules/gltf/editor/editor_import_blend_runner.cpp b/modules/gltf/editor/editor_import_blend_runner.cpp index 22c8adfe888..82d74e38e82 100644 --- a/modules/gltf/editor/editor_import_blend_runner.cpp +++ b/modules/gltf/editor/editor_import_blend_runner.cpp @@ -94,9 +94,9 @@ bpy.ops.export_scene.gltf(**opts['gltf_options']) String dict_to_python(const Dictionary &p_dict) { String entries; - Array dict_keys = p_dict.keys(); - for (int i = 0; i < dict_keys.size(); i++) { - const String key = dict_keys[i]; + List dict_keys; + p_dict.get_key_list(&dict_keys); + for (const String key : dict_keys) { String value; Variant raw_value = p_dict[key]; @@ -127,9 +127,9 @@ String dict_to_python(const Dictionary &p_dict) { String dict_to_xmlrpc(const Dictionary &p_dict) { String members; - Array dict_keys = p_dict.keys(); - for (int i = 0; i < dict_keys.size(); i++) { - const String key = dict_keys[i]; + List dict_keys; + p_dict.get_key_list(&dict_keys); + for (const String key : dict_keys) { String value; Variant raw_value = p_dict[key]; diff --git a/modules/gltf/gltf_template_convert.h b/modules/gltf/gltf_template_convert.h index 46f185867ae..4fca5b59c06 100644 --- a/modules/gltf/gltf_template_convert.h +++ b/modules/gltf/gltf_template_convert.h @@ -85,9 +85,10 @@ static Dictionary to_dictionary(const HashMap &p_inp) { template static void set_from_dictionary(HashMap &r_out, const Dictionary &p_inp) { r_out.clear(); - Array keys = p_inp.keys(); - for (int i = 0; i < keys.size(); i++) { - r_out[keys[i]] = p_inp[keys[i]]; + List keys; + p_inp.get_key_list(&keys); + for (const Variant &key : keys) { + r_out[key] = p_inp[key]; } } } //namespace GLTFTemplateConvert diff --git a/modules/gltf/structures/gltf_skin.cpp b/modules/gltf/structures/gltf_skin.cpp index 18aa90a628c..f8a3b2a8129 100644 --- a/modules/gltf/structures/gltf_skin.cpp +++ b/modules/gltf/structures/gltf_skin.cpp @@ -145,9 +145,10 @@ Dictionary GLTFSkin::get_joint_i_to_name() { void GLTFSkin::set_joint_i_to_name(Dictionary p_joint_i_to_name) { joint_i_to_name = HashMap(); - Array keys = p_joint_i_to_name.keys(); - for (int i = 0; i < keys.size(); i++) { - joint_i_to_name[keys[i]] = p_joint_i_to_name[keys[i]]; + List keys; + p_joint_i_to_name.get_key_list(&keys); + for (const Variant &key : keys) { + joint_i_to_name[key] = p_joint_i_to_name[key]; } } diff --git a/modules/openxr/editor/openxr_select_runtime.cpp b/modules/openxr/editor/openxr_select_runtime.cpp index 4a2a87cb886..884b9e5a637 100644 --- a/modules/openxr/editor/openxr_select_runtime.cpp +++ b/modules/openxr/editor/openxr_select_runtime.cpp @@ -55,9 +55,9 @@ void OpenXRSelectRuntime::_update_items() { set_item_metadata(index, ""); index++; - Array keys = runtimes.keys(); - for (int i = 0; i < keys.size(); i++) { - String key = keys[i]; + List keys; + runtimes.get_key_list(&keys); + for (const String key : keys) { String path = runtimes[key]; String adj_path = path.replace("~", home_folder); diff --git a/modules/openxr/extensions/openxr_extension_wrapper_extension.cpp b/modules/openxr/extensions/openxr_extension_wrapper_extension.cpp index 07ca476421d..da3a9280aba 100644 --- a/modules/openxr/extensions/openxr_extension_wrapper_extension.cpp +++ b/modules/openxr/extensions/openxr_extension_wrapper_extension.cpp @@ -76,9 +76,9 @@ HashMap OpenXRExtensionWrapperExtension::get_requested_extension if (GDVIRTUAL_CALL(_get_requested_extensions, request_extension)) { HashMap result; - Array keys = request_extension.keys(); - for (int i = 0; i < keys.size(); i++) { - String key = keys.get(i); + List keys; + request_extension.get_key_list(&keys); + for (const String key : keys) { GDExtensionPtr value = VariantCaster>::cast(request_extension.get(key, GDExtensionPtr(nullptr))); result.insert(key, value); } diff --git a/scene/gui/code_edit.cpp b/scene/gui/code_edit.cpp index 635228670d0..eafcde2238e 100644 --- a/scene/gui/code_edit.cpp +++ b/scene/gui/code_edit.cpp @@ -1225,9 +1225,10 @@ void CodeEdit::add_auto_brace_completion_pair(const String &p_open_key, const St void CodeEdit::set_auto_brace_completion_pairs(const Dictionary &p_auto_brace_completion_pairs) { auto_brace_completion_pairs.clear(); - Array keys = p_auto_brace_completion_pairs.keys(); - for (int i = 0; i < keys.size(); i++) { - add_auto_brace_completion_pair(keys[i], p_auto_brace_completion_pairs[keys[i]]); + List keys; + p_auto_brace_completion_pairs.get_key_list(&keys); + for (const Variant &key : keys) { + add_auto_brace_completion_pair(key, p_auto_brace_completion_pairs[key]); } }