From 746dddc0673d7261f19b1e056e90e6e3a49ef33a Mon Sep 17 00:00:00 2001 From: reduz Date: Fri, 13 May 2022 15:04:37 +0200 Subject: Replace most uses of Map by HashMap * Map is unnecessary and inefficient in almost every case. * Replaced by the new HashMap. * Renamed Map to RBMap and Set to RBSet for cases that still make sense (order matters) but use is discouraged. There were very few cases where replacing by HashMap was undesired because keeping the key order was intended. I tried to keep those (as RBMap) as much as possible, but might have missed some. Review appreciated! --- editor/editor_export.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'editor/editor_export.cpp') diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index ef99425f68..f0eea50d3a 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -95,7 +95,7 @@ Ref EditorExportPreset::get_platform() const { void EditorExportPreset::update_files_to_export() { Vector to_remove; - for (Set::Element *E = selected_files.front(); E; E = E->next()) { + for (RBSet::Element *E = selected_files.front(); E; E = E->next()) { if (!FileAccess::exists(E->get())) { to_remove.push_back(E->get()); } @@ -107,7 +107,7 @@ void EditorExportPreset::update_files_to_export() { Vector EditorExportPreset::get_files_to_export() const { Vector files; - for (Set::Element *E = selected_files.front(); E; E = E->next()) { + for (RBSet::Element *E = selected_files.front(); E; E = E->next()) { files.push_back(E->get()); } return files; @@ -446,7 +446,7 @@ Ref EditorExportPlatform::create_preset() { return preset; } -void EditorExportPlatform::_export_find_resources(EditorFileSystemDirectory *p_dir, Set &p_paths) { +void EditorExportPlatform::_export_find_resources(EditorFileSystemDirectory *p_dir, RBSet &p_paths) { for (int i = 0; i < p_dir->get_subdir_count(); i++) { _export_find_resources(p_dir->get_subdir(i), p_paths); } @@ -459,7 +459,7 @@ void EditorExportPlatform::_export_find_resources(EditorFileSystemDirectory *p_d } } -void EditorExportPlatform::_export_find_dependencies(const String &p_path, Set &p_paths) { +void EditorExportPlatform::_export_find_dependencies(const String &p_path, RBSet &p_paths) { if (p_paths.has(p_path)) { return; } @@ -480,7 +480,7 @@ void EditorExportPlatform::_export_find_dependencies(const String &p_path, Set &da, const Vector &p_filters, Set &r_list, bool exclude) { +void EditorExportPlatform::_edit_files_with_filter(Ref &da, const Vector &p_filters, RBSet &r_list, bool exclude) { da->list_dir_begin(); String cur_dir = da->get_current_dir().replace("\\", "/"); if (!cur_dir.ends_with("/")) { @@ -528,7 +528,7 @@ void EditorExportPlatform::_edit_files_with_filter(Ref &da, const Vec } } -void EditorExportPlatform::_edit_filter_list(Set &r_list, const String &p_filter, bool exclude) { +void EditorExportPlatform::_edit_filter_list(RBSet &r_list, const String &p_filter, bool exclude) { if (p_filter.is_empty()) { return; } @@ -648,10 +648,10 @@ void EditorExportPlugin::_export_end_script() { GDVIRTUAL_CALL(_export_end); } -void EditorExportPlugin::_export_file(const String &p_path, const String &p_type, const Set &p_features) { +void EditorExportPlugin::_export_file(const String &p_path, const String &p_type, const RBSet &p_features) { } -void EditorExportPlugin::_export_begin(const Set &p_features, bool p_debug, const String &p_path, int p_flags) { +void EditorExportPlugin::_export_begin(const RBSet &p_features, bool p_debug, const String &p_path, int p_flags) { } void EditorExportPlugin::skip() { @@ -739,7 +739,7 @@ EditorExportPlatform::ExportNotifier::~ExportNotifier() { Error EditorExportPlatform::export_project_files(const Ref &p_preset, bool p_debug, EditorExportSaveFunction p_func, void *p_udata, EditorExportSaveSharedObject p_so_func) { //figure out paths of files that will be exported - Set paths; + RBSet paths; Vector path_remaps; if (p_preset->get_export_filter() == EditorExportPreset::EXPORT_ALL_RESOURCES) { @@ -872,14 +872,14 @@ Error EditorExportPlatform::export_project_files(const Ref & } FeatureContainers feature_containers = get_feature_containers(p_preset, p_debug); - Set &features = feature_containers.features; + RBSet &features = feature_containers.features; Vector &features_pv = feature_containers.features_pv; //store everything in the export medium int idx = 0; int total = paths.size(); - for (Set::Element *E = paths.front(); E; E = E->next()) { + for (RBSet::Element *E = paths.front(); E; E = E->next()) { String path = E->get(); String type = ResourceLoader::get_resource_type(path); @@ -910,7 +910,7 @@ Error EditorExportPlatform::export_project_files(const Ref & List remaps; config->get_section_keys("remap", &remaps); - Set remap_features; + RBSet remap_features; for (const String &F : remaps) { String remap = F; @@ -1669,7 +1669,7 @@ void EditorExport::load_config() { } void EditorExport::update_export_presets() { - Map> platform_options; + HashMap> platform_options; for (int i = 0; i < export_platforms.size(); i++) { Ref platform = export_platforms[i]; @@ -1691,7 +1691,7 @@ void EditorExport::update_export_presets() { List options = platform_options[preset->get_platform()->get_name()]; // Copy the previous preset values - Map previous_values = preset->values; + HashMap previous_values = preset->values; // Clear the preset properties and values prior to reloading preset->properties.clear(); @@ -1934,7 +1934,7 @@ void EditorExportPlatformPC::get_platform_features(List *r_features) { r_features->push_back(get_os_name().to_lower()); //OS name is a feature } -void EditorExportPlatformPC::resolve_platform_feature_priorities(const Ref &p_preset, Set &p_features) { +void EditorExportPlatformPC::resolve_platform_feature_priorities(const Ref &p_preset, RBSet &p_features) { if (p_features.has("bptc")) { if (p_preset->has("texture_format/no_bptc_fallbacks")) { p_features.erase("s3tc"); @@ -1952,7 +1952,7 @@ void EditorExportPlatformPC::set_chmod_flags(int p_flags) { /////////////////////// -void EditorExportTextSceneToBinaryPlugin::_export_file(const String &p_path, const String &p_type, const Set &p_features) { +void EditorExportTextSceneToBinaryPlugin::_export_file(const String &p_path, const String &p_type, const RBSet &p_features) { String extension = p_path.get_extension().to_lower(); if (extension != "tres" && extension != "tscn") { return; -- cgit v1.2.3