summaryrefslogtreecommitdiffstats
path: root/editor/editor_resource_picker.cpp
diff options
context:
space:
mode:
authorreduz <reduzio@gmail.com>2022-05-13 15:04:37 +0200
committerRémi Verschelde <rverschelde@gmail.com>2022-05-16 10:37:48 +0200
commit746dddc0673d7261f19b1e056e90e6e3a49ef33a (patch)
tree434b526eb286850ebccc6d2c998a7d90fdb8b5e2 /editor/editor_resource_picker.cpp
parent396def9b66c476f7834604adb7136ca903ed01be (diff)
downloadredot-engine-746dddc0673d7261f19b1e056e90e6e3a49ef33a.tar.gz
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!
Diffstat (limited to 'editor/editor_resource_picker.cpp')
-rw-r--r--editor/editor_resource_picker.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/editor/editor_resource_picker.cpp b/editor/editor_resource_picker.cpp
index 3158c03dcc..41d769ad1f 100644
--- a/editor/editor_resource_picker.cpp
+++ b/editor/editor_resource_picker.cpp
@@ -240,7 +240,7 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) {
ResourceLoader::get_recognized_extensions_for_type(base, &extensions);
}
- Set<String> valid_extensions;
+ RBSet<String> valid_extensions;
for (const String &E : extensions) {
valid_extensions.insert(E);
}
@@ -253,7 +253,7 @@ void EditorResourcePicker::_edit_menu_cbk(int p_which) {
}
file_dialog->clear_filters();
- for (Set<String>::Element *E = valid_extensions.front(); E; E = E->next()) {
+ for (RBSet<String>::Element *E = valid_extensions.front(); E; E = E->next()) {
file_dialog->add_filter("*." + E->get() + " ; " + E->get().to_upper());
}
@@ -409,7 +409,7 @@ void EditorResourcePicker::set_create_options(Object *p_menu_node) {
if (!base_type.is_empty()) {
int idx = 0;
- Set<String> allowed_types;
+ RBSet<String> allowed_types;
_get_allowed_types(false, &allowed_types);
Vector<EditorData::CustomType> custom_resources;
@@ -417,7 +417,7 @@ void EditorResourcePicker::set_create_options(Object *p_menu_node) {
custom_resources = EditorNode::get_editor_data().get_custom_types()["Resource"];
}
- for (Set<String>::Element *E = allowed_types.front(); E; E = E->next()) {
+ for (RBSet<String>::Element *E = allowed_types.front(); E; E = E->next()) {
const String &t = E->get();
bool is_custom_resource = false;
@@ -491,7 +491,7 @@ void EditorResourcePicker::_button_input(const Ref<InputEvent> &p_event) {
}
}
-void EditorResourcePicker::_get_allowed_types(bool p_with_convert, Set<String> *p_vector) const {
+void EditorResourcePicker::_get_allowed_types(bool p_with_convert, RBSet<String> *p_vector) const {
Vector<String> allowed_types = base_type.split(",");
int size = allowed_types.size();
@@ -568,7 +568,7 @@ bool EditorResourcePicker::_is_drop_valid(const Dictionary &p_drag_data) const {
res = drag_data["resource"];
}
- Set<String> allowed_types;
+ RBSet<String> allowed_types;
_get_allowed_types(true, &allowed_types);
if (res.is_valid() && _is_type_valid(res->get_class(), allowed_types)) {
@@ -598,8 +598,8 @@ bool EditorResourcePicker::_is_drop_valid(const Dictionary &p_drag_data) const {
return false;
}
-bool EditorResourcePicker::_is_type_valid(const String p_type_name, Set<String> p_allowed_types) const {
- for (Set<String>::Element *E = p_allowed_types.front(); E; E = E->next()) {
+bool EditorResourcePicker::_is_type_valid(const String p_type_name, RBSet<String> p_allowed_types) const {
+ for (RBSet<String>::Element *E = p_allowed_types.front(); E; E = E->next()) {
String at = E->get().strip_edges();
if (p_type_name == at || ClassDB::is_parent_class(p_type_name, at) || EditorNode::get_editor_data().script_class_is_parent(p_type_name, at)) {
return true;
@@ -646,12 +646,12 @@ void EditorResourcePicker::drop_data_fw(const Point2 &p_point, const Variant &p_
}
if (dropped_resource.is_valid()) {
- Set<String> allowed_types;
+ RBSet<String> allowed_types;
_get_allowed_types(false, &allowed_types);
// If the accepted dropped resource is from the extended list, it requires conversion.
if (!_is_type_valid(dropped_resource->get_class(), allowed_types)) {
- for (Set<String>::Element *E = allowed_types.front(); E; E = E->next()) {
+ for (RBSet<String>::Element *E = allowed_types.front(); E; E = E->next()) {
String at = E->get().strip_edges();
if (at == "BaseMaterial3D" && Ref<Texture2D>(dropped_resource).is_valid()) {
@@ -768,7 +768,7 @@ void EditorResourcePicker::set_base_type(const String &p_base_type) {
// There is a possibility that the new base type is conflicting with the existing value.
// Keep the value, but warn the user that there is a potential mistake.
if (!base_type.is_empty() && edited_resource.is_valid()) {
- Set<String> allowed_types;
+ RBSet<String> allowed_types;
_get_allowed_types(true, &allowed_types);
StringName custom_class;
@@ -784,7 +784,7 @@ void EditorResourcePicker::set_base_type(const String &p_base_type) {
}
} else {
// Call the method to build the cache immediately.
- Set<String> allowed_types;
+ RBSet<String> allowed_types;
_get_allowed_types(false, &allowed_types);
}
}
@@ -794,7 +794,7 @@ String EditorResourcePicker::get_base_type() const {
}
Vector<String> EditorResourcePicker::get_allowed_types() const {
- Set<String> allowed_types;
+ RBSet<String> allowed_types;
_get_allowed_types(false, &allowed_types);
Vector<String> types;
@@ -802,7 +802,7 @@ Vector<String> EditorResourcePicker::get_allowed_types() const {
int i = 0;
String *w = types.ptrw();
- for (Set<String>::Element *E = allowed_types.front(); E; E = E->next(), i++) {
+ for (RBSet<String>::Element *E = allowed_types.front(); E; E = E->next(), i++) {
w[i] = E->get();
}
@@ -817,7 +817,7 @@ void EditorResourcePicker::set_edited_resource(Ref<Resource> p_resource) {
}
if (!base_type.is_empty()) {
- Set<String> allowed_types;
+ RBSet<String> allowed_types;
_get_allowed_types(true, &allowed_types);
StringName custom_class;