Cleanup: remove redundant checks & assignments

This commit is contained in:
Campbell Barton
2024-04-11 20:33:00 +10:00
parent 271aedffbe
commit 3a8cceee7d
7 changed files with 10 additions and 13 deletions
@@ -1207,12 +1207,11 @@ bool armature_bonecoll_is_child_of(const bArmature *armature,
const int potential_child_index)
{
/* Check for roots, before we try and access collection_array[-1]. */
const bool is_root = armature_bonecoll_is_root(armature, potential_child_index);
if (is_root) {
if (armature_bonecoll_is_root(armature, potential_child_index)) {
return potential_parent_index == -1;
}
if (potential_parent_index < 0) {
return is_root;
return false;
}
const BoneCollection *potential_parent = armature->collection_array[potential_parent_index];
+1 -2
View File
@@ -1348,12 +1348,11 @@ OceanCache *BKE_ocean_init_cache(const char *bakepath,
void BKE_ocean_simulate_cache(OceanCache *och, int frame)
{
char filepath[FILE_MAX];
int f = frame;
/* ibufs array is zero based, but filenames are based on frame numbers */
/* still need to clamp frame numbers to valid range of images on disk though */
CLAMP(frame, och->start, och->end);
f = frame - och->start; /* shift to 0 based */
const int f = frame - och->start; /* shift to 0 based */
/* if image is already loaded in mem, return */
if (och->ibufs_disp[f] != nullptr) {
+1 -1
View File
@@ -1669,7 +1669,7 @@ template<typename T>
MatBase<T, 4, 4> result = mat;
const bool is_perspective = mat[2][3] == -1.0f;
const bool is_perspective_infinite = mat[2][2] == -1.0f;
if (is_perspective | is_perspective_infinite) {
if (is_perspective || is_perspective_infinite) {
result[2][0] -= mat[0][0] * offset.x / math::length(float3(mat[0][0], mat[1][0], mat[2][0]));
result[2][1] -= mat[1][1] * offset.y / math::length(float3(mat[0][1], mat[1][1], mat[2][1]));
}
+2 -2
View File
@@ -1204,8 +1204,8 @@ static int delete_soft(const char *file, const char **error_message)
const char *args[5];
const char *process_failed;
char *xdg_current_desktop = getenv("XDG_CURRENT_DESKTOP");
char *xdg_session_desktop = getenv("XDG_SESSION_DESKTOP");
const char *xdg_current_desktop = getenv("XDG_CURRENT_DESKTOP");
const char *xdg_session_desktop = getenv("XDG_SESSION_DESKTOP");
if ((xdg_current_desktop != nullptr && STREQ(xdg_current_desktop, "KDE")) ||
(xdg_session_desktop != nullptr && STREQ(xdg_session_desktop, "KDE")))
+2 -4
View File
@@ -53,11 +53,10 @@ bool BLI_tridiagonal_solve(
size_t bytes = sizeof(double) * (uint)count;
double *c1 = (double *)MEM_mallocN(bytes * 2, "tridiagonal_c1d1");
double *d1 = c1 + count;
if (!c1) {
return false;
}
double *d1 = c1 + count;
int i;
double c_prev, d_prev, x_prev;
@@ -120,11 +119,10 @@ bool BLI_tridiagonal_solve_cyclic(
size_t bytes = sizeof(float) * (uint)count;
float *tmp = (float *)MEM_mallocN(bytes * 2, "tridiagonal_ex");
float *b2 = tmp + count;
if (!tmp) {
return false;
}
float *b2 = tmp + count;
/* Prepare the non-cyclic system; relies on tridiagonal_solve ignoring values. */
memcpy(b2, b, bytes);
@@ -291,6 +291,7 @@ static bool view3d_ruler_pick(wmGizmoGroup *gzgroup,
}
}
}
UNUSED_VARS(dist_best);
*r_co_index = co_index_best;
return found;
@@ -498,7 +498,7 @@ static bool rna_property_override_operation_store(Main *bmain,
}
}
if (ptr_storage != nullptr && prop_storage->magic == RNA_MAGIC &&
if ((prop_storage->magic == RNA_MAGIC) &&
!ELEM(prop_storage->override_store, nullptr, override_store))
{
override_store = nullptr;