Use `Dictionary.get_key_list` where appropriate
This commit is contained in:
parent
76a135926a
commit
ac07977fbd
|
@ -467,17 +467,18 @@ void DependencyRemoveDialog::_find_localization_remaps_of_removed_files(Vector<R
|
|||
p_removed.push_back(dep);
|
||||
}
|
||||
|
||||
Array remap_keys = remaps.keys();
|
||||
for (int j = 0; j < remap_keys.size(); j++) {
|
||||
PackedStringArray remapped_files = remaps[remap_keys[j]];
|
||||
for (int k = 0; k < remapped_files.size(); k++) {
|
||||
int splitter_pos = remapped_files[k].rfind(":");
|
||||
String res_path = remapped_files[k].substr(0, splitter_pos);
|
||||
List<Variant> 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;
|
||||
|
|
|
@ -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<Variant> 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];
|
||||
}
|
||||
|
|
|
@ -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<Variant> 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));
|
||||
|
|
|
@ -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<Variant> 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"];
|
||||
|
|
|
@ -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<Variant> 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Variant> 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<Node>(keys[i]);
|
||||
for (const Variant &key : keys) {
|
||||
Node *node = Object::cast_to<Node>(key);
|
||||
Node3D *sp = Object::cast_to<Node3D>(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<Node>(keys[i]);
|
||||
for (const Variant &key : keys) {
|
||||
Node *node = Object::cast_to<Node>(key);
|
||||
Node3D *sp = Object::cast_to<Node3D>(node);
|
||||
Dictionary d = snap_data[node];
|
||||
Vector3 from = d["from"];
|
||||
|
|
|
@ -2128,12 +2128,11 @@ void VisualShaderEditor::_update_nodes() {
|
|||
}
|
||||
}
|
||||
|
||||
Array keys = added.keys();
|
||||
List<Variant> 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"]);
|
||||
|
|
|
@ -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<Variant> 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<Variant> dict_keys;
|
||||
p_dict.get_key_list(&dict_keys);
|
||||
for (const String key : dict_keys) {
|
||||
String value;
|
||||
Variant raw_value = p_dict[key];
|
||||
|
||||
|
|
|
@ -85,9 +85,10 @@ static Dictionary to_dictionary(const HashMap<K, V> &p_inp) {
|
|||
template <typename K, typename V>
|
||||
static void set_from_dictionary(HashMap<K, V> &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<Variant> keys;
|
||||
p_inp.get_key_list(&keys);
|
||||
for (const Variant &key : keys) {
|
||||
r_out[key] = p_inp[key];
|
||||
}
|
||||
}
|
||||
} //namespace GLTFTemplateConvert
|
||||
|
|
|
@ -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<int, StringName>();
|
||||
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<Variant> 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];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Variant> keys;
|
||||
runtimes.get_key_list(&keys);
|
||||
for (const String key : keys) {
|
||||
String path = runtimes[key];
|
||||
String adj_path = path.replace("~", home_folder);
|
||||
|
||||
|
|
|
@ -76,9 +76,9 @@ HashMap<String, bool *> OpenXRExtensionWrapperExtension::get_requested_extension
|
|||
|
||||
if (GDVIRTUAL_CALL(_get_requested_extensions, request_extension)) {
|
||||
HashMap<String, bool *> result;
|
||||
Array keys = request_extension.keys();
|
||||
for (int i = 0; i < keys.size(); i++) {
|
||||
String key = keys.get(i);
|
||||
List<Variant> keys;
|
||||
request_extension.get_key_list(&keys);
|
||||
for (const String key : keys) {
|
||||
GDExtensionPtr<bool> value = VariantCaster<GDExtensionPtr<bool>>::cast(request_extension.get(key, GDExtensionPtr<bool>(nullptr)));
|
||||
result.insert(key, value);
|
||||
}
|
||||
|
|
|
@ -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<Variant> 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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue