You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-22 15:06:45 +00:00
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!
This commit is contained in:
@@ -726,7 +726,7 @@ void FileSystemDock::_sort_file_info_list(List<FileSystemDock::FileInfo> &r_file
|
||||
|
||||
void FileSystemDock::_update_file_list(bool p_keep_selection) {
|
||||
// Register the previously selected items.
|
||||
Set<String> cselection;
|
||||
RBSet<String> cselection;
|
||||
if (p_keep_selection) {
|
||||
for (int i = 0; i < files->get_item_count(); i++) {
|
||||
if (files->is_selected(i)) {
|
||||
@@ -1161,7 +1161,7 @@ void FileSystemDock::_get_all_items_in_dir(EditorFileSystemDirectory *efsd, Vect
|
||||
}
|
||||
}
|
||||
|
||||
void FileSystemDock::_find_remaps(EditorFileSystemDirectory *efsd, const Map<String, String> &renames, Vector<String> &to_remaps) const {
|
||||
void FileSystemDock::_find_remaps(EditorFileSystemDirectory *efsd, const HashMap<String, String> &renames, Vector<String> &to_remaps) const {
|
||||
for (int i = 0; i < efsd->get_subdir_count(); i++) {
|
||||
_find_remaps(efsd->get_subdir(i), renames, to_remaps);
|
||||
}
|
||||
@@ -1177,7 +1177,7 @@ void FileSystemDock::_find_remaps(EditorFileSystemDirectory *efsd, const Map<Str
|
||||
}
|
||||
|
||||
void FileSystemDock::_try_move_item(const FileOrFolder &p_item, const String &p_new_path,
|
||||
Map<String, String> &p_file_renames, Map<String, String> &p_folder_renames) {
|
||||
HashMap<String, String> &p_file_renames, HashMap<String, String> &p_folder_renames) {
|
||||
// Ensure folder paths end with "/".
|
||||
String old_path = (p_item.is_file || p_item.path.ends_with("/")) ? p_item.path : (p_item.path + "/");
|
||||
String new_path = (p_item.is_file || p_new_path.ends_with("/")) ? p_new_path : (p_new_path + "/");
|
||||
@@ -1301,7 +1301,7 @@ void FileSystemDock::_try_duplicate_item(const FileOrFolder &p_item, const Strin
|
||||
}
|
||||
}
|
||||
|
||||
void FileSystemDock::_update_resource_paths_after_move(const Map<String, String> &p_renames) const {
|
||||
void FileSystemDock::_update_resource_paths_after_move(const HashMap<String, String> &p_renames) const {
|
||||
// Rename all resources loaded, be it subresources or actual resources.
|
||||
List<Ref<Resource>> cached;
|
||||
ResourceCache::get_cached_resources(&cached);
|
||||
@@ -1346,7 +1346,7 @@ void FileSystemDock::_update_resource_paths_after_move(const Map<String, String>
|
||||
}
|
||||
}
|
||||
|
||||
void FileSystemDock::_update_dependencies_after_move(const Map<String, String> &p_renames) const {
|
||||
void FileSystemDock::_update_dependencies_after_move(const HashMap<String, String> &p_renames) const {
|
||||
// The following code assumes that the following holds:
|
||||
// 1) EditorFileSystem contains the old paths/folder structure from before the rename/move.
|
||||
// 2) ResourceLoader can use the new paths without needing to call rescan.
|
||||
@@ -1367,9 +1367,9 @@ void FileSystemDock::_update_dependencies_after_move(const Map<String, String> &
|
||||
}
|
||||
}
|
||||
|
||||
void FileSystemDock::_update_project_settings_after_move(const Map<String, String> &p_renames) const {
|
||||
void FileSystemDock::_update_project_settings_after_move(const HashMap<String, String> &p_renames) const {
|
||||
// Find all project settings of type FILE and replace them if needed.
|
||||
const Map<StringName, PropertyInfo> prop_info = ProjectSettings::get_singleton()->get_custom_property_info();
|
||||
const HashMap<StringName, PropertyInfo> prop_info = ProjectSettings::get_singleton()->get_custom_property_info();
|
||||
for (const KeyValue<StringName, PropertyInfo> &E : prop_info) {
|
||||
if (E.value.hint == PROPERTY_HINT_FILE) {
|
||||
String old_path = GLOBAL_GET(E.key);
|
||||
@@ -1398,7 +1398,7 @@ void FileSystemDock::_update_project_settings_after_move(const Map<String, Strin
|
||||
ProjectSettings::get_singleton()->save();
|
||||
}
|
||||
|
||||
void FileSystemDock::_update_favorites_list_after_move(const Map<String, String> &p_files_renames, const Map<String, String> &p_folders_renames) const {
|
||||
void FileSystemDock::_update_favorites_list_after_move(const HashMap<String, String> &p_files_renames, const HashMap<String, String> &p_folders_renames) const {
|
||||
Vector<String> favorites = EditorSettings::get_singleton()->get_favorites();
|
||||
Vector<String> new_favorites;
|
||||
|
||||
@@ -1416,7 +1416,7 @@ void FileSystemDock::_update_favorites_list_after_move(const Map<String, String>
|
||||
EditorSettings::get_singleton()->set_favorites(new_favorites);
|
||||
}
|
||||
|
||||
void FileSystemDock::_save_scenes_after_move(const Map<String, String> &p_renames) const {
|
||||
void FileSystemDock::_save_scenes_after_move(const HashMap<String, String> &p_renames) const {
|
||||
Vector<String> remaps;
|
||||
_find_remaps(EditorFileSystem::get_singleton()->get_filesystem(), p_renames, remaps);
|
||||
Vector<String> new_filenames;
|
||||
@@ -1577,8 +1577,8 @@ void FileSystemDock::_rename_operation_confirm() {
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, String> file_renames;
|
||||
Map<String, String> folder_renames;
|
||||
HashMap<String, String> file_renames;
|
||||
HashMap<String, String> folder_renames;
|
||||
_try_move_item(to_rename, new_path, file_renames, folder_renames);
|
||||
|
||||
int current_tab = EditorNode::get_singleton()->get_current_tab();
|
||||
@@ -1677,8 +1677,8 @@ void FileSystemDock::_move_operation_confirm(const String &p_to_path, bool p_ove
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, String> file_renames;
|
||||
Map<String, String> folder_renames;
|
||||
HashMap<String, String> file_renames;
|
||||
HashMap<String, String> folder_renames;
|
||||
bool is_moved = false;
|
||||
for (int i = 0; i < to_move.size(); i++) {
|
||||
String old_path = to_move[i].path.ends_with("/") ? to_move[i].path.substr(0, to_move[i].path.length() - 1) : to_move[i].path;
|
||||
|
||||
Reference in New Issue
Block a user