Browse Source

Remove duplicate data structure for export features

Aaron Franke 3 years ago
parent
commit
28d1bc34d7
2 changed files with 20 additions and 23 deletions
  1. 19 17
      editor/export/editor_export_platform.cpp
  2. 1 6
      editor/export/editor_export_platform.h

+ 19 - 17
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);
 	_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();
 	Ref<EditorExportPlatform> platform = p_preset->get_platform();
 	List<String> feature_list;
 	List<String> feature_list;
 	platform->get_platform_features(&feature_list);
 	platform->get_platform_features(&feature_list);
 	platform->get_preset_features(p_preset, &feature_list);
 	platform->get_preset_features(p_preset, &feature_list);
 
 
-	FeatureContainers result;
+	HashSet<String> result;
 	for (const String &E : feature_list) {
 	for (const String &E : feature_list) {
-		result.features.insert(E);
-		result.features_pv.push_back(E);
+		result.insert(E);
 	}
 	}
 
 
 	if (p_debug) {
 	if (p_debug) {
-		result.features.insert("debug");
-		result.features_pv.push_back("debug");
+		result.insert("debug");
 	} else {
 	} else {
-		result.features.insert("release");
-		result.features_pv.push_back("release");
+		result.insert("release");
 	}
 	}
 
 
 	if (!p_preset->get_custom_features().is_empty()) {
 	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++) {
 		for (int i = 0; i < tmp_custom_list.size(); i++) {
 			String f = tmp_custom_list[i].strip_edges();
 			String f = tmp_custom_list[i].strip_edges();
 			if (!f.is_empty()) {
 			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) {
 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();
 	Vector<Ref<EditorExportPlugin>> export_plugins = EditorExport::get_singleton()->get_export_plugins();
 	//initial export plugin callback
 	//initial export plugin callback
 	for (int i = 0; i < export_plugins.size(); i++) {
 	for (int i = 0; i < export_plugins.size(); i++) {
 		if (export_plugins[i]->get_script_instance()) { //script based
 		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 {
 		} 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();
 		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
 	//store everything in the export medium
 	int idx = 0;
 	int idx = 0;
@@ -709,7 +707,11 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> &
 			bool do_export = true;
 			bool do_export = true;
 			for (int i = 0; i < export_plugins.size(); i++) {
 			for (int i = 0; i < export_plugins.size(); i++) {
 				if (export_plugins[i]->get_script_instance()) { //script based
 				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 {
 				} else {
 					export_plugins.write[i]->_export_file(path, type, features);
 					export_plugins.write[i]->_export_file(path, type, features);
 				}
 				}

+ 1 - 6
editor/export/editor_export_platform.h

@@ -85,11 +85,6 @@ private:
 		EditorProgress *ep = nullptr;
 		EditorProgress *ep = nullptr;
 	};
 	};
 
 
-	struct FeatureContainers {
-		HashSet<String> features;
-		Vector<String> features_pv;
-	};
-
 	Vector<ExportMessage> messages;
 	Vector<ExportMessage> messages;
 
 
 	void _export_find_resources(EditorFileSystemDirectory *p_dir, HashSet<String> &p_paths);
 	void _export_find_resources(EditorFileSystemDirectory *p_dir, HashSet<String> &p_paths);
@@ -110,7 +105,7 @@ protected:
 		~ExportNotifier();
 		~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;
 	bool exists_export_template(String template_file_name, String *err) const;
 	String find_export_template(String template_file_name, String *err = nullptr) const;
 	String find_export_template(String template_file_name, String *err = nullptr) const;