diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-08-10 09:55:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-10 09:55:59 +0200 |
commit | 94a8065ae4ae19b814bc9b02d41358d55d3cf813 (patch) | |
tree | 43b546e667aba9436f6849a73816f511b2e18fda | |
parent | 317ced8204d80367c445963fc989de320c6f9a68 (diff) | |
parent | 28d1bc34d7a5535cd15edab4edc8bcbefdcf7090 (diff) |
Merge pull request #62722 from aaronfranke/there-can-be-only-one
Remove duplicate data structure for editor export features
-rw-r--r-- | editor/export/editor_export_platform.cpp | 36 | ||||
-rw-r--r-- | editor/export/editor_export_platform.h | 7 |
2 files changed, 20 insertions, 23 deletions
diff --git a/editor/export/editor_export_platform.cpp b/editor/export/editor_export_platform.cpp index 34b407779e..b4d3973705 100644 --- a/editor/export/editor_export_platform.cpp +++ b/editor/export/editor_export_platform.cpp @@ -429,24 +429,21 @@ void EditorExportPlatform::_edit_filter_list(HashSet<String> &r_list, const Stri _edit_files_with_filter(da, filters, r_list, exclude); } -EditorExportPlatform::FeatureContainers EditorExportPlatform::get_feature_containers(const Ref<EditorExportPreset> &p_preset, bool p_debug) const { +HashSet<String> EditorExportPlatform::get_features(const Ref<EditorExportPreset> &p_preset, bool p_debug) const { Ref<EditorExportPlatform> platform = p_preset->get_platform(); List<String> feature_list; platform->get_platform_features(&feature_list); platform->get_preset_features(p_preset, &feature_list); - FeatureContainers result; + HashSet<String> result; for (const String &E : feature_list) { - result.features.insert(E); - result.features_pv.push_back(E); + result.insert(E); } if (p_debug) { - result.features.insert("debug"); - result.features_pv.push_back("debug"); + result.insert("debug"); } else { - result.features.insert("release"); - result.features_pv.push_back("release"); + result.insert("release"); } if (!p_preset->get_custom_features().is_empty()) { @@ -455,8 +452,7 @@ EditorExportPlatform::FeatureContainers EditorExportPlatform::get_feature_contai for (int i = 0; i < tmp_custom_list.size(); i++) { String f = tmp_custom_list[i].strip_edges(); if (!f.is_empty()) { - result.features.insert(f); - result.features_pv.push_back(f); + result.insert(f); } } } @@ -465,14 +461,18 @@ EditorExportPlatform::FeatureContainers EditorExportPlatform::get_feature_contai } EditorExportPlatform::ExportNotifier::ExportNotifier(EditorExportPlatform &p_platform, const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) { - FeatureContainers features = p_platform.get_feature_containers(p_preset, p_debug); + HashSet<String> features = p_platform.get_features(p_preset, p_debug); Vector<Ref<EditorExportPlugin>> export_plugins = EditorExport::get_singleton()->get_export_plugins(); //initial export plugin callback for (int i = 0; i < export_plugins.size(); i++) { if (export_plugins[i]->get_script_instance()) { //script based - export_plugins.write[i]->_export_begin_script(features.features_pv, p_debug, p_path, p_flags); + PackedStringArray features_psa; + for (const String &feature : features) { + features_psa.push_back(feature); + } + export_plugins.write[i]->_export_begin_script(features_psa, p_debug, p_path, p_flags); } else { - export_plugins.write[i]->_export_begin(features.features, p_debug, p_path, p_flags); + export_plugins.write[i]->_export_begin(features, p_debug, p_path, p_flags); } } } @@ -621,9 +621,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & export_plugins.write[i]->_clear(); } - FeatureContainers feature_containers = get_feature_containers(p_preset, p_debug); - HashSet<String> &features = feature_containers.features; - Vector<String> &features_pv = feature_containers.features_pv; + HashSet<String> features = get_features(p_preset, p_debug); //store everything in the export medium int idx = 0; @@ -709,7 +707,11 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & bool do_export = true; for (int i = 0; i < export_plugins.size(); i++) { if (export_plugins[i]->get_script_instance()) { //script based - export_plugins.write[i]->_export_file_script(path, type, features_pv); + PackedStringArray features_psa; + for (const String &feature : features) { + features_psa.push_back(feature); + } + export_plugins.write[i]->_export_file_script(path, type, features_psa); } else { export_plugins.write[i]->_export_file(path, type, features); } diff --git a/editor/export/editor_export_platform.h b/editor/export/editor_export_platform.h index 832a0cf846..ad1bcc1996 100644 --- a/editor/export/editor_export_platform.h +++ b/editor/export/editor_export_platform.h @@ -85,11 +85,6 @@ private: EditorProgress *ep = nullptr; }; - struct FeatureContainers { - HashSet<String> features; - Vector<String> features_pv; - }; - Vector<ExportMessage> messages; void _export_find_resources(EditorFileSystemDirectory *p_dir, HashSet<String> &p_paths); @@ -110,7 +105,7 @@ protected: ~ExportNotifier(); }; - FeatureContainers get_feature_containers(const Ref<EditorExportPreset> &p_preset, bool p_debug) const; + HashSet<String> get_features(const Ref<EditorExportPreset> &p_preset, bool p_debug) const; bool exists_export_template(String template_file_name, String *err) const; String find_export_template(String template_file_name, String *err = nullptr) const; |