diff options
author | Aaron Record <aaronjrecord@gmail.com> | 2022-05-18 17:43:40 -0600 |
---|---|---|
committer | Aaron Record <aaronjrecord@gmail.com> | 2022-05-19 12:09:16 +0200 |
commit | 900c676b0282bed83d00834e3c280ac89c2bc94d (patch) | |
tree | b6bf869a55440a666f4bcc17d5e9cd93ff26dbdc /core | |
parent | 71c40ff4da85a4770958533cdc65f2c9f7ddeaff (diff) |
Use range iterators for RBSet in most cases
Diffstat (limited to 'core')
-rw-r--r-- | core/config/project_settings.cpp | 16 | ||||
-rw-r--r-- | core/io/file_access_pack.cpp | 4 | ||||
-rw-r--r-- | core/io/resource.cpp | 4 | ||||
-rw-r--r-- | core/io/resource_loader.cpp | 4 | ||||
-rw-r--r-- | core/math/a_star.cpp | 6 | ||||
-rw-r--r-- | core/multiplayer/multiplayer_api.cpp | 4 | ||||
-rw-r--r-- | core/string/translation.cpp | 12 |
7 files changed, 25 insertions, 25 deletions
diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 4638d70e59..ff5ff83bf8 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -360,8 +360,8 @@ void ProjectSettings::_get_property_list(List<PropertyInfo> *p_list) const { vclist.insert(vc); } - for (RBSet<_VCSort>::Element *E = vclist.front(); E; E = E->next()) { - String prop_info_name = E->get().name; + for (const _VCSort &E : vclist) { + String prop_info_name = E.name; int dot = prop_info_name.find("."); if (dot != -1 && !custom_prop_info.has(prop_info_name)) { prop_info_name = prop_info_name.substr(0, dot); @@ -369,11 +369,11 @@ void ProjectSettings::_get_property_list(List<PropertyInfo> *p_list) const { if (custom_prop_info.has(prop_info_name)) { PropertyInfo pi = custom_prop_info[prop_info_name]; - pi.name = E->get().name; - pi.usage = E->get().flags; + pi.name = E.name; + pi.usage = E.flags; p_list->push_back(pi); } else { - p_list->push_back(PropertyInfo(E->get().type, E->get().name, PROPERTY_HINT_NONE, "", E->get().flags)); + p_list->push_back(PropertyInfo(E.type, E.name, PROPERTY_HINT_NONE, "", E.flags)); } } } @@ -959,9 +959,9 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust RBMap<String, List<String>> props; - for (RBSet<_VCSort>::Element *E = vclist.front(); E; E = E->next()) { - String category = E->get().name; - String name = E->get().name; + for (const _VCSort &E : vclist) { + String category = E.name; + String name = E.name; int div = category.find("/"); diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index 89efdc4938..595a6e9873 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -406,8 +406,8 @@ Error DirAccessPack::list_dir_begin() { list_dirs.push_back(E.key); } - for (RBSet<String>::Element *E = current->files.front(); E; E = E->next()) { - list_files.push_back(E->get()); + for (const String &E : current->files) { + list_files.push_back(E); } return OK; diff --git a/core/io/resource.cpp b/core/io/resource.cpp index 4a94c17132..ad01eb1083 100644 --- a/core/io/resource.cpp +++ b/core/io/resource.cpp @@ -317,8 +317,8 @@ void Resource::unregister_owner(Object *p_owner) { } void Resource::notify_change_to_owners() { - for (RBSet<ObjectID>::Element *E = owners.front(); E; E = E->next()) { - Object *obj = ObjectDB::get_instance(E->get()); + for (const ObjectID &E : owners) { + Object *obj = ObjectDB::get_instance(E); ERR_CONTINUE_MSG(!obj, "Object was deleted, while still owning a resource."); //wtf //TODO store string obj->call("resource_changed", Ref<Resource>(this)); diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index 9e6330f34b..fb21db1a19 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -391,8 +391,8 @@ float ResourceLoader::_dependency_get_progress(const String &p_path) { int dep_count = load_task.sub_tasks.size(); if (dep_count > 0) { float dep_progress = 0; - for (RBSet<String>::Element *E = load_task.sub_tasks.front(); E; E = E->next()) { - dep_progress += _dependency_get_progress(E->get()); + for (const String &E : load_task.sub_tasks) { + dep_progress += _dependency_get_progress(E); } dep_progress /= float(dep_count); dep_progress *= 0.5; diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp index a3ee259030..29aa959e54 100644 --- a/core/math/a_star.cpp +++ b/core/math/a_star.cpp @@ -293,10 +293,10 @@ Vector3 AStar3D::get_closest_position_in_segment(const Vector3 &p_point) const { real_t closest_dist = 1e20; Vector3 closest_point; - for (const RBSet<Segment>::Element *E = segments.front(); E; E = E->next()) { + for (const Segment &E : segments) { Point *from_point = nullptr, *to_point = nullptr; - points.lookup(E->get().u, from_point); - points.lookup(E->get().v, to_point); + points.lookup(E.u, from_point); + points.lookup(E.v, to_point); if (!(from_point->enabled && to_point->enabled)) { continue; diff --git a/core/multiplayer/multiplayer_api.cpp b/core/multiplayer/multiplayer_api.cpp index e18c3dd2e4..9605647b3f 100644 --- a/core/multiplayer/multiplayer_api.cpp +++ b/core/multiplayer/multiplayer_api.cpp @@ -494,8 +494,8 @@ Vector<int> MultiplayerAPI::get_peer_ids() const { ERR_FAIL_COND_V_MSG(!multiplayer_peer.is_valid(), Vector<int>(), "No multiplayer peer is assigned. Assume no peers are connected."); Vector<int> ret; - for (RBSet<int>::Element *E = connected_peers.front(); E; E = E->next()) { - ret.push_back(E->get()); + for (const int &E : connected_peers) { + ret.push_back(E); } return ret; diff --git a/core/string/translation.cpp b/core/string/translation.cpp index c64f815563..cba2f09022 100644 --- a/core/string/translation.cpp +++ b/core/string/translation.cpp @@ -507,8 +507,8 @@ String TranslationServer::get_locale() const { Array TranslationServer::get_loaded_locales() const { Array locales; - for (const RBSet<Ref<Translation>>::Element *E = translations.front(); E; E = E->next()) { - const Ref<Translation> &t = E->get(); + for (const Ref<Translation> &E : translations) { + const Ref<Translation> &t = E; ERR_FAIL_COND_V(t.is_null(), Array()); String l = t->get_locale(); @@ -530,8 +530,8 @@ Ref<Translation> TranslationServer::get_translation_object(const String &p_local Ref<Translation> res; int best_score = 0; - for (const RBSet<Ref<Translation>>::Element *E = translations.front(); E; E = E->next()) { - const Ref<Translation> &t = E->get(); + for (const Ref<Translation> &E : translations) { + const Ref<Translation> &t = E; ERR_FAIL_COND_V(t.is_null(), nullptr); String l = t->get_locale(); @@ -599,8 +599,8 @@ StringName TranslationServer::_get_message_from_translations(const StringName &p StringName res; int best_score = 0; - for (const RBSet<Ref<Translation>>::Element *E = translations.front(); E; E = E->next()) { - const Ref<Translation> &t = E->get(); + for (const Ref<Translation> &E : translations) { + const Ref<Translation> &t = E; ERR_FAIL_COND_V(t.is_null(), p_message); String l = t->get_locale(); |