diff options
author | Hans Goudey <h.goudey@me.com> | 2021-12-09 23:34:15 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-12-09 23:34:15 +0300 |
commit | 74a566d211e011abb10ba3d1878287341f6f177b (patch) | |
tree | 75fe72c571e81a3c5fbdc8958c5d8d2f326af44f | |
parent | b8f41825e85779bfddad24c76bd3111b0544ecc3 (diff) |
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.
-rw-r--r-- | source/blender/blenkernel/intern/geometry_set.cc | 32 |
1 files 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<MeshComponent>(); + return; } - else { - MeshComponent &component = this->get_component_for_write<MeshComponent>(); - component.replace(mesh, ownership); - } + + MeshComponent &component = this->get_component_for_write<MeshComponent>(); + component.replace(mesh, ownership); } void GeometrySet::replace_curve(CurveEval *curve, GeometryOwnershipType ownership) { if (curve == nullptr) { this->remove<CurveComponent>(); + return; } - else { - CurveComponent &component = this->get_component_for_write<CurveComponent>(); - component.replace(curve, ownership); - } + + CurveComponent &component = this->get_component_for_write<CurveComponent>(); + component.replace(curve, ownership); } void GeometrySet::replace_pointcloud(PointCloud *pointcloud, GeometryOwnershipType ownership) { if (pointcloud == nullptr) { this->remove<PointCloudComponent>(); + return; } - else { - PointCloudComponent &component = this->get_component_for_write<PointCloudComponent>(); - component.replace(pointcloud, ownership); - } + + PointCloudComponent &component = this->get_component_for_write<PointCloudComponent>(); + component.replace(pointcloud, ownership); } void GeometrySet::replace_volume(Volume *volume, GeometryOwnershipType ownership) { if (volume == nullptr) { this->remove<VolumeComponent>(); + return; } - else { - VolumeComponent &component = this->get_component_for_write<VolumeComponent>(); - component.replace(volume, ownership); - } + + VolumeComponent &component = this->get_component_for_write<VolumeComponent>(); + component.replace(volume, ownership); } Mesh *GeometrySet::get_mesh_for_write() |