You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-10 13:00:37 +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:
@@ -99,7 +99,7 @@ void FindInFiles::set_folder(String folder) {
|
||||
_root_dir = folder;
|
||||
}
|
||||
|
||||
void FindInFiles::set_filter(const Set<String> &exts) {
|
||||
void FindInFiles::set_filter(const RBSet<String> &exts) {
|
||||
_extension_filter = exts;
|
||||
}
|
||||
|
||||
@@ -443,9 +443,9 @@ String FindInFilesDialog::get_folder() const {
|
||||
return text.strip_edges();
|
||||
}
|
||||
|
||||
Set<String> FindInFilesDialog::get_filter() const {
|
||||
RBSet<String> FindInFilesDialog::get_filter() const {
|
||||
// Could check the _filters_preferences but it might not have been generated yet.
|
||||
Set<String> filters;
|
||||
RBSet<String> filters;
|
||||
for (int i = 0; i < _filters_container->get_child_count(); ++i) {
|
||||
CheckBox *cb = static_cast<CheckBox *>(_filters_container->get_child(i));
|
||||
if (cb->is_pressed()) {
|
||||
@@ -701,9 +701,9 @@ void FindInFilesPanel::_notification(int p_what) {
|
||||
|
||||
void FindInFilesPanel::_on_result_found(String fpath, int line_number, int begin, int end, String text) {
|
||||
TreeItem *file_item;
|
||||
Map<String, TreeItem *>::Element *E = _file_items.find(fpath);
|
||||
HashMap<String, TreeItem *>::Iterator E = _file_items.find(fpath);
|
||||
|
||||
if (E == nullptr) {
|
||||
if (!E) {
|
||||
file_item = _results_display->create_item();
|
||||
file_item->set_text(0, fpath);
|
||||
file_item->set_metadata(0, fpath);
|
||||
@@ -715,7 +715,7 @@ void FindInFilesPanel::_on_result_found(String fpath, int line_number, int begin
|
||||
|
||||
_file_items[fpath] = file_item;
|
||||
} else {
|
||||
file_item = E->value();
|
||||
file_item = E->value;
|
||||
}
|
||||
|
||||
int text_index = _with_replace ? 1 : 0;
|
||||
@@ -754,11 +754,11 @@ void FindInFilesPanel::draw_result_text(Object *item_obj, Rect2 rect) {
|
||||
return;
|
||||
}
|
||||
|
||||
Map<TreeItem *, Result>::Element *E = _result_items.find(item);
|
||||
HashMap<TreeItem *, Result>::Iterator E = _result_items.find(item);
|
||||
if (!E) {
|
||||
return;
|
||||
}
|
||||
Result r = E->value();
|
||||
Result r = E->value;
|
||||
String item_text = item->get_text(_with_replace ? 1 : 0);
|
||||
Ref<Font> font = _results_display->get_theme_font(SNAME("font"));
|
||||
int font_size = _results_display->get_theme_font_size(SNAME("font_size"));
|
||||
@@ -818,12 +818,12 @@ void FindInFilesPanel::_on_cancel_button_clicked() {
|
||||
|
||||
void FindInFilesPanel::_on_result_selected() {
|
||||
TreeItem *item = _results_display->get_selected();
|
||||
Map<TreeItem *, Result>::Element *E = _result_items.find(item);
|
||||
HashMap<TreeItem *, Result>::Iterator E = _result_items.find(item);
|
||||
|
||||
if (E == nullptr) {
|
||||
if (!E) {
|
||||
return;
|
||||
}
|
||||
Result r = E->value();
|
||||
Result r = E->value;
|
||||
|
||||
TreeItem *file_item = item->get_parent();
|
||||
String fpath = file_item->get_metadata(0);
|
||||
@@ -850,9 +850,9 @@ void FindInFilesPanel::_on_replace_all_clicked() {
|
||||
continue;
|
||||
}
|
||||
|
||||
Map<TreeItem *, Result>::Element *F = _result_items.find(item);
|
||||
ERR_FAIL_COND(F == nullptr);
|
||||
locations.push_back(F->value());
|
||||
HashMap<TreeItem *, Result>::Iterator F = _result_items.find(item);
|
||||
ERR_FAIL_COND(!F);
|
||||
locations.push_back(F->value);
|
||||
}
|
||||
|
||||
if (locations.size() != 0) {
|
||||
|
||||
Reference in New Issue
Block a user