From b280699078eee23bd8eb572668d6f0d8972d879a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 20 Oct 2021 10:45:59 +1100 Subject: Cleanup: use elem macros --- source/blender/blenlib/intern/boxpack_2d.c | 8 ++++---- source/blender/blenlib/intern/delaunay_2d.cc | 4 ++-- source/blender/blenlib/intern/filereader_gzip.c | 2 +- source/blender/blenlib/intern/noise.cc | 2 +- source/blender/blenlib/intern/scanfill_utils.c | 6 ++---- 5 files changed, 10 insertions(+), 12 deletions(-) (limited to 'source/blender/blenlib') diff --git a/source/blender/blenlib/intern/boxpack_2d.c b/source/blender/blenlib/intern/boxpack_2d.c index 4a07f1134d0..cf5831cada5 100644 --- a/source/blender/blenlib/intern/boxpack_2d.c +++ b/source/blender/blenlib/intern/boxpack_2d.c @@ -516,7 +516,7 @@ void BLI_box_pack_2d(BoxPack *boxarray, const uint len, float *r_tot_x, float *r * flag verts on one or both of the boxes * as being used by checking the width or * height of both boxes */ - if (vert->tlb && vert->trb && (box == vert->tlb || box == vert->trb)) { + if (vert->tlb && vert->trb && (ELEM(box, vert->tlb, vert->trb))) { if (UNLIKELY(fabsf(vert->tlb->h - vert->trb->h) < EPSILON_MERGE)) { #ifdef USE_MERGE # define A (vert->trb->v[TL]) @@ -547,7 +547,7 @@ void BLI_box_pack_2d(BoxPack *boxarray, const uint len, float *r_tot_x, float *r vert->tlb->v[TR]->free &= ~(TRF | BRF); } } - else if (vert->blb && vert->brb && (box == vert->blb || box == vert->brb)) { + else if (vert->blb && vert->brb && (ELEM(box, vert->blb, vert->brb))) { if (UNLIKELY(fabsf(vert->blb->h - vert->brb->h) < EPSILON_MERGE)) { #ifdef USE_MERGE # define A (vert->blb->v[BR]) @@ -579,7 +579,7 @@ void BLI_box_pack_2d(BoxPack *boxarray, const uint len, float *r_tot_x, float *r } } /* Horizontal */ - if (vert->tlb && vert->blb && (box == vert->tlb || box == vert->blb)) { + if (vert->tlb && vert->blb && (ELEM(box, vert->tlb, vert->blb))) { if (UNLIKELY(fabsf(vert->tlb->w - vert->blb->w) < EPSILON_MERGE)) { #ifdef USE_MERGE # define A (vert->blb->v[TL]) @@ -610,7 +610,7 @@ void BLI_box_pack_2d(BoxPack *boxarray, const uint len, float *r_tot_x, float *r vert->tlb->v[BL]->free &= ~(BLF | BRF); } } - else if (vert->trb && vert->brb && (box == vert->trb || box == vert->brb)) { + else if (vert->trb && vert->brb && (ELEM(box, vert->trb, vert->brb))) { if (UNLIKELY(fabsf(vert->trb->w - vert->brb->w) < EPSILON_MERGE)) { #ifdef USE_MERGE diff --git a/source/blender/blenlib/intern/delaunay_2d.cc b/source/blender/blenlib/intern/delaunay_2d.cc index 4582ea69d9b..53e881a9fc7 100644 --- a/source/blender/blenlib/intern/delaunay_2d.cc +++ b/source/blender/blenlib/intern/delaunay_2d.cc @@ -2274,8 +2274,8 @@ void add_face_constraints(CDT_state *cdt_state, * making valid BMesh faces. */ int id = cdt_state->need_ids ? f : 0; add_face_ids(cdt_state, face_symedge0, id, fedge_start, fedge_end); - if (cdt_state->need_ids || (output_type == CDT_CONSTRAINTS_VALID_BMESH || - output_type == CDT_CONSTRAINTS_VALID_BMESH_WITH_HOLES)) { + if (cdt_state->need_ids || + ELEM(output_type, CDT_CONSTRAINTS_VALID_BMESH, CDT_CONSTRAINTS_VALID_BMESH_WITH_HOLES)) { add_face_ids(cdt_state, face_symedge0, f, fedge_start, fedge_end); } } diff --git a/source/blender/blenlib/intern/filereader_gzip.c b/source/blender/blenlib/intern/filereader_gzip.c index 72eb153a8b9..fe766e5da41 100644 --- a/source/blender/blenlib/intern/filereader_gzip.c +++ b/source/blender/blenlib/intern/filereader_gzip.c @@ -64,7 +64,7 @@ static ssize_t gzip_read(FileReader *reader, void *buffer, size_t size) int ret = inflate(&gzip->strm, Z_NO_FLUSH); - if (ret != Z_OK && ret != Z_BUF_ERROR) { + if (!ELEM(ret, Z_OK, Z_BUF_ERROR)) { break; } } diff --git a/source/blender/blenlib/intern/noise.cc b/source/blender/blenlib/intern/noise.cc index 58b6bb638e9..5fa2746d07f 100644 --- a/source/blender/blenlib/intern/noise.cc +++ b/source/blender/blenlib/intern/noise.cc @@ -410,7 +410,7 @@ BLI_INLINE float noise_grad(uint32_t hash, float x, float y, float z) { uint32_t h = hash & 15u; float u = h < 8u ? x : y; - float vt = ((h == 12u) || (h == 14u)) ? x : z; + float vt = ELEM(h, 12u, 14u) ? x : z; float v = h < 4u ? y : vt; return negate_if(u, h & 1u) + negate_if(v, h & 2u); } diff --git a/source/blender/blenlib/intern/scanfill_utils.c b/source/blender/blenlib/intern/scanfill_utils.c index ec0f8659395..33c0f4afd01 100644 --- a/source/blender/blenlib/intern/scanfill_utils.c +++ b/source/blender/blenlib/intern/scanfill_utils.c @@ -156,15 +156,13 @@ static ScanFillEdge *edge_step(PolyInfo *poly_info, eed = (e_curr->next && e_curr != poly_info[poly_nr].edge_last) ? e_curr->next : poly_info[poly_nr].edge_first; - if ((v_curr == eed->v1 || v_curr == eed->v2) == true && - (ELEM(v_prev, eed->v1, eed->v2)) == false) { + if (ELEM(v_curr, eed->v1, eed->v2) == true && ELEM(v_prev, eed->v1, eed->v2) == false) { return eed; } eed = (e_curr->prev && e_curr != poly_info[poly_nr].edge_first) ? e_curr->prev : poly_info[poly_nr].edge_last; - if ((v_curr == eed->v1 || v_curr == eed->v2) == true && - (ELEM(v_prev, eed->v1, eed->v2)) == false) { + if (ELEM(v_curr, eed->v1, eed->v2) == true && ELEM(v_prev, eed->v1, eed->v2) == false) { return eed; } -- cgit v1.2.3