From 74a566d211e011abb10ba3d1878287341f6f177b Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Thu, 9 Dec 2021 14:34:15 -0600 Subject: Cleanup: Return early in null check I'm planning to make these functions slightly more complicated, and it makes sense to return early when checking one of the parameters for null anyway. --- source/blender/blenkernel/intern/geometry_set.cc | 32 ++++++++++++------------ 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/source/blender/blenkernel/intern/geometry_set.cc b/source/blender/blenkernel/intern/geometry_set.cc index 3e812a7e3c5..214d88d1a63 100644 --- a/source/blender/blenkernel/intern/geometry_set.cc +++ b/source/blender/blenkernel/intern/geometry_set.cc @@ -351,44 +351,44 @@ void GeometrySet::replace_mesh(Mesh *mesh, GeometryOwnershipType ownership) { if (mesh == nullptr) { this->remove(); + return; } - else { - MeshComponent &component = this->get_component_for_write(); - component.replace(mesh, ownership); - } + + MeshComponent &component = this->get_component_for_write(); + component.replace(mesh, ownership); } void GeometrySet::replace_curve(CurveEval *curve, GeometryOwnershipType ownership) { if (curve == nullptr) { this->remove(); + return; } - else { - CurveComponent &component = this->get_component_for_write(); - component.replace(curve, ownership); - } + + CurveComponent &component = this->get_component_for_write(); + component.replace(curve, ownership); } void GeometrySet::replace_pointcloud(PointCloud *pointcloud, GeometryOwnershipType ownership) { if (pointcloud == nullptr) { this->remove(); + return; } - else { - PointCloudComponent &component = this->get_component_for_write(); - component.replace(pointcloud, ownership); - } + + PointCloudComponent &component = this->get_component_for_write(); + component.replace(pointcloud, ownership); } void GeometrySet::replace_volume(Volume *volume, GeometryOwnershipType ownership) { if (volume == nullptr) { this->remove(); + return; } - else { - VolumeComponent &component = this->get_component_for_write(); - component.replace(volume, ownership); - } + + VolumeComponent &component = this->get_component_for_write(); + component.replace(volume, ownership); } Mesh *GeometrySet::get_mesh_for_write() -- cgit v1.2.3