From 900c676b0282bed83d00834e3c280ac89c2bc94d Mon Sep 17 00:00:00 2001 From: Aaron Record Date: Wed, 18 May 2022 17:43:40 -0600 Subject: Use range iterators for RBSet in most cases --- drivers/gles3/storage/material_storage.cpp | 24 ++++++++++++------------ drivers/gles3/storage/mesh_storage.cpp | 12 ++++++------ 2 files changed, 18 insertions(+), 18 deletions(-) (limited to 'drivers/gles3/storage') diff --git a/drivers/gles3/storage/material_storage.cpp b/drivers/gles3/storage/material_storage.cpp index e93c503396..7b18376a2a 100644 --- a/drivers/gles3/storage/material_storage.cpp +++ b/drivers/gles3/storage/material_storage.cpp @@ -2091,8 +2091,8 @@ void MaterialStorage::global_variable_set(const StringName &p_name, const Varian } else { //texture MaterialStorage *material_storage = MaterialStorage::get_singleton(); - for (RBSet::Element *E = gv.texture_materials.front(); E; E = E->next()) { - Material *material = material_storage->get_material(E->get()); + for (const RID &E : gv.texture_materials) { + Material *material = material_storage->get_material(E); ERR_CONTINUE(!material); material_storage->_material_queue_update(material, false, true); } @@ -2123,8 +2123,8 @@ void MaterialStorage::global_variable_set_override(const StringName &p_name, con } else { //texture MaterialStorage *material_storage = MaterialStorage::get_singleton(); - for (RBSet::Element *E = gv.texture_materials.front(); E; E = E->next()) { - Material *material = material_storage->get_material(E->get()); + for (const RID &E : gv.texture_materials) { + Material *material = material_storage->get_material(E); ERR_CONTINUE(!material); material_storage->_material_queue_update(material, false, true); } @@ -2421,8 +2421,8 @@ void MaterialStorage::shader_set_code(RID p_shader, const String &p_code) { shader->data = nullptr; } - for (RBSet::Element *E = shader->owners.front(); E; E = E->next()) { - Material *material = E->get(); + for (Material *E : shader->owners) { + Material *material = E; material->shader_mode = new_mode; if (material->data) { memdelete(material->data); @@ -2438,8 +2438,8 @@ void MaterialStorage::shader_set_code(RID p_shader, const String &p_code) { shader->mode = RS::SHADER_MAX; //invalid } - for (RBSet::Element *E = shader->owners.front(); E; E = E->next()) { - Material *material = E->get(); + for (Material *E : shader->owners) { + Material *material = E; if (shader->data) { material->data = material_data_request_func[new_mode](shader->data); material->data->self = material->self; @@ -2462,8 +2462,8 @@ void MaterialStorage::shader_set_code(RID p_shader, const String &p_code) { shader->data->set_code(p_code); } - for (RBSet::Element *E = shader->owners.front(); E; E = E->next()) { - Material *material = E->get(); + for (Material *E : shader->owners) { + Material *material = E; material->dependency.changed_notify(RendererStorage::DEPENDENCY_CHANGED_MATERIAL); _material_queue_update(material, true, true); } @@ -2504,8 +2504,8 @@ void MaterialStorage::shader_set_default_texture_param(RID p_shader, const Strin if (shader->data) { shader->data->set_default_texture_param(p_name, p_texture, p_index); } - for (RBSet::Element *E = shader->owners.front(); E; E = E->next()) { - Material *material = E->get(); + for (Material *E : shader->owners) { + Material *material = E; _material_queue_update(material, false, true); } } diff --git a/drivers/gles3/storage/mesh_storage.cpp b/drivers/gles3/storage/mesh_storage.cpp index 5739a63cac..3be1792868 100644 --- a/drivers/gles3/storage/mesh_storage.cpp +++ b/drivers/gles3/storage/mesh_storage.cpp @@ -68,8 +68,8 @@ void MeshStorage::mesh_free(RID p_rid) { ERR_PRINT("deleting mesh with active instances"); } if (mesh->shadow_owners.size()) { - for (RBSet::Element *E = mesh->shadow_owners.front(); E; E = E->next()) { - Mesh *shadow_owner = E->get(); + for (Mesh *E : mesh->shadow_owners) { + Mesh *shadow_owner = E; shadow_owner->shadow_mesh = RID(); shadow_owner->dependency.changed_notify(RendererStorage::DEPENDENCY_CHANGED_MESH); } @@ -268,8 +268,8 @@ void MeshStorage::mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface) mesh->dependency.changed_notify(RendererStorage::DEPENDENCY_CHANGED_MESH); - for (RBSet::Element *E = mesh->shadow_owners.front(); E; E = E->next()) { - Mesh *shadow_owner = E->get(); + for (Mesh *E : mesh->shadow_owners) { + Mesh *shadow_owner = E; shadow_owner->shadow_mesh = RID(); shadow_owner->dependency.changed_notify(RendererStorage::DEPENDENCY_CHANGED_MESH); } @@ -610,8 +610,8 @@ void MeshStorage::mesh_clear(RID p_mesh) { mesh->has_bone_weights = false; mesh->dependency.changed_notify(RendererStorage::DEPENDENCY_CHANGED_MESH); - for (RBSet::Element *E = mesh->shadow_owners.front(); E; E = E->next()) { - Mesh *shadow_owner = E->get(); + for (Mesh *E : mesh->shadow_owners) { + Mesh *shadow_owner = E; shadow_owner->shadow_mesh = RID(); shadow_owner->dependency.changed_notify(RendererStorage::DEPENDENCY_CHANGED_MESH); } -- cgit v1.2.3