[Bf-blender-cvs] [f11f7ce08e9] master: Cleanup: use ELEM macro (>2 args)

Campbell Barton noreply at git.blender.org
Fri Nov 6 02:54:41 CET 2020


Commit: f11f7ce08e92463b8a7495ed60082546f228cb60
Author: Campbell Barton
Date:   Fri Nov 6 12:51:49 2020 +1100
Branches: master
https://developer.blender.org/rBf11f7ce08e92463b8a7495ed60082546f228cb60

Cleanup: use ELEM macro (>2 args)

===================================================================

M	source/blender/blenkernel/intern/fluid.c
M	source/blender/blenkernel/intern/mball_tessellate.c
M	source/blender/blenkernel/intern/particle.c
M	source/blender/blenkernel/intern/particle_system.c
M	source/blender/blenkernel/intern/text.c
M	source/blender/blenlib/tests/BLI_delaunay_2d_test.cc
M	source/blender/compositor/intern/COM_Converter.cpp
M	source/blender/editors/interface/interface_layout.c
M	source/blender/editors/interface/interface_utils.c
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/space_text/text_ops.c
M	source/blender/gpu/opengl/gl_vertex_array.cc
M	source/blender/imbuf/intern/cineon/dpxlib.c
M	source/blender/modifiers/intern/MOD_skin.c
M	source/blender/python/generic/blf_py_api.c
M	source/blender/python/mathutils/mathutils_Matrix.c

===================================================================

diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c
index f5bbccb2618..a940a8a97c7 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -4697,9 +4697,11 @@ void BKE_fluid_fields_sanitize(FluidDomainSettings *settings)
   const char data_depth = settings->openvdb_data_depth;
 
   if (settings->type == FLUID_DOMAIN_TYPE_GAS) {
-    if (coba_field == FLUID_DOMAIN_FIELD_PHI || coba_field == FLUID_DOMAIN_FIELD_PHI_IN ||
-        coba_field == FLUID_DOMAIN_FIELD_PHI_OUT ||
-        coba_field == FLUID_DOMAIN_FIELD_PHI_OBSTACLE) {
+    if (ELEM(coba_field,
+             FLUID_DOMAIN_FIELD_PHI,
+             FLUID_DOMAIN_FIELD_PHI_IN,
+             FLUID_DOMAIN_FIELD_PHI_OUT,
+             FLUID_DOMAIN_FIELD_PHI_OBSTACLE)) {
       /* Defaulted to density for gas domain. */
       settings->coba_field = FLUID_DOMAIN_FIELD_DENSITY;
     }
@@ -4710,10 +4712,14 @@ void BKE_fluid_fields_sanitize(FluidDomainSettings *settings)
     }
   }
   else if (settings->type == FLUID_DOMAIN_TYPE_LIQUID) {
-    if (coba_field == FLUID_DOMAIN_FIELD_COLOR_R || coba_field == FLUID_DOMAIN_FIELD_COLOR_G ||
-        coba_field == FLUID_DOMAIN_FIELD_COLOR_B || coba_field == FLUID_DOMAIN_FIELD_DENSITY ||
-        coba_field == FLUID_DOMAIN_FIELD_FLAME || coba_field == FLUID_DOMAIN_FIELD_FUEL ||
-        coba_field == FLUID_DOMAIN_FIELD_HEAT) {
+    if (ELEM(coba_field,
+             FLUID_DOMAIN_FIELD_COLOR_R,
+             FLUID_DOMAIN_FIELD_COLOR_G,
+             FLUID_DOMAIN_FIELD_COLOR_B,
+             FLUID_DOMAIN_FIELD_DENSITY,
+             FLUID_DOMAIN_FIELD_FLAME,
+             FLUID_DOMAIN_FIELD_FUEL,
+             FLUID_DOMAIN_FIELD_HEAT)) {
       /* Defaulted to phi for liquid domain. */
       settings->coba_field = FLUID_DOMAIN_FIELD_PHI;
     }
diff --git a/source/blender/blenkernel/intern/mball_tessellate.c b/source/blender/blenkernel/intern/mball_tessellate.c
index 7273d2a920d..cb01927d992 100644
--- a/source/blender/blenkernel/intern/mball_tessellate.c
+++ b/source/blender/blenkernel/intern/mball_tessellate.c
@@ -807,22 +807,22 @@ static void makecubetable(void)
       INTLIST *edges;
 
       for (edges = polys->list; edges; edges = edges->next) {
-        if (edges->i == LB || edges->i == LT || edges->i == LN || edges->i == LF) {
+        if (ELEM(edges->i, LB, LT, LN, LF)) {
           faces[i] |= 1 << L;
         }
-        if (edges->i == RB || edges->i == RT || edges->i == RN || edges->i == RF) {
+        if (ELEM(edges->i, RB, RT, RN, RF)) {
           faces[i] |= 1 << R;
         }
-        if (edges->i == LB || edges->i == RB || edges->i == BN || edges->i == BF) {
+        if (ELEM(edges->i, LB, RB, BN, BF)) {
           faces[i] |= 1 << B;
         }
-        if (edges->i == LT || edges->i == RT || edges->i == TN || edges->i == TF) {
+        if (ELEM(edges->i, LT, RT, TN, TF)) {
           faces[i] |= 1 << T;
         }
-        if (edges->i == LN || edges->i == RN || edges->i == BN || edges->i == TN) {
+        if (ELEM(edges->i, LN, RN, BN, TN)) {
           faces[i] |= 1 << N;
         }
-        if (edges->i == LF || edges->i == RF || edges->i == BF || edges->i == TF) {
+        if (ELEM(edges->i, LF, RF, BF, TF)) {
           faces[i] |= 1 << F;
         }
       }
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 108a43981a5..abcd0b0e0e4 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -3997,19 +3997,25 @@ void object_remove_particle_system(Main *bmain, Scene *UNUSED(scene), Object *ob
       if (psys->part->type == PART_FLUID_FLIP) {
         fmd->domain->particle_type &= ~FLUID_DOMAIN_PARTICLE_FLIP;
       }
-      if (psys->part->type == PART_FLUID_SPRAY || psys->part->type == PART_FLUID_SPRAYFOAM ||
-          psys->part->type == PART_FLUID_SPRAYBUBBLE ||
-          psys->part->type == PART_FLUID_SPRAYFOAMBUBBLE) {
+      if (ELEM(psys->part->type,
+               PART_FLUID_SPRAY,
+               PART_FLUID_SPRAYFOAM,
+               PART_FLUID_SPRAYBUBBLE,
+               PART_FLUID_SPRAYFOAMBUBBLE)) {
         fmd->domain->particle_type &= ~FLUID_DOMAIN_PARTICLE_SPRAY;
       }
-      if (psys->part->type == PART_FLUID_FOAM || psys->part->type == PART_FLUID_SPRAYFOAM ||
-          psys->part->type == PART_FLUID_FOAMBUBBLE ||
-          psys->part->type == PART_FLUID_SPRAYFOAMBUBBLE) {
+      if (ELEM(psys->part->type,
+               PART_FLUID_FOAM,
+               PART_FLUID_SPRAYFOAM,
+               PART_FLUID_FOAMBUBBLE,
+               PART_FLUID_SPRAYFOAMBUBBLE)) {
         fmd->domain->particle_type &= ~FLUID_DOMAIN_PARTICLE_FOAM;
       }
-      if (psys->part->type == PART_FLUID_BUBBLE || psys->part->type == PART_FLUID_FOAMBUBBLE ||
-          psys->part->type == PART_FLUID_SPRAYBUBBLE ||
-          psys->part->type == PART_FLUID_SPRAYFOAMBUBBLE) {
+      if (ELEM(psys->part->type,
+               PART_FLUID_BUBBLE,
+               PART_FLUID_FOAMBUBBLE,
+               PART_FLUID_SPRAYBUBBLE,
+               PART_FLUID_SPRAYFOAMBUBBLE)) {
         fmd->domain->particle_type &= ~FLUID_DOMAIN_PARTICLE_BUBBLE;
       }
       if (psys->part->type == PART_FLUID_TRACER) {
@@ -4017,9 +4023,11 @@ void object_remove_particle_system(Main *bmain, Scene *UNUSED(scene), Object *ob
       }
 
       /* Disable combined export if combined particle system was deleted. */
-      if (psys->part->type == PART_FLUID_SPRAYFOAM || psys->part->type == PART_FLUID_SPRAYBUBBLE ||
-          psys->part->type == PART_FLUID_FOAMBUBBLE ||
-          psys->part->type == PART_FLUID_SPRAYFOAMBUBBLE) {
+      if (ELEM(psys->part->type,
+               PART_FLUID_SPRAYFOAM,
+               PART_FLUID_SPRAYBUBBLE,
+               PART_FLUID_FOAMBUBBLE,
+               PART_FLUID_SPRAYFOAMBUBBLE)) {
         fmd->domain->sndparticle_combined_export = SNDPARTICLE_COMBINED_EXPORT_OFF;
       }
     }
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 58264432cdf..91bdfaeae95 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -4151,20 +4151,17 @@ static bool particles_has_tracer(short parttype)
 
 static bool particles_has_spray(short parttype)
 {
-  return ((parttype == PART_FLUID_SPRAY) || (parttype == PART_FLUID_SPRAYFOAM) ||
-          (parttype == PART_FLUID_SPRAYFOAMBUBBLE));
+  return (ELEM(parttype, PART_FLUID_SPRAY, PART_FLUID_SPRAYFOAM, PART_FLUID_SPRAYFOAMBUBBLE));
 }
 
 static bool particles_has_bubble(short parttype)
 {
-  return ((parttype == PART_FLUID_BUBBLE) || (parttype == PART_FLUID_FOAMBUBBLE) ||
-          (parttype == PART_FLUID_SPRAYFOAMBUBBLE));
+  return (ELEM(parttype, PART_FLUID_BUBBLE, PART_FLUID_FOAMBUBBLE, PART_FLUID_SPRAYFOAMBUBBLE));
 }
 
 static bool particles_has_foam(short parttype)
 {
-  return ((parttype == PART_FLUID_FOAM) || (parttype == PART_FLUID_SPRAYFOAM) ||
-          (parttype == PART_FLUID_SPRAYFOAMBUBBLE));
+  return (ELEM(parttype, PART_FLUID_FOAM, PART_FLUID_SPRAYFOAM, PART_FLUID_SPRAYFOAMBUBBLE));
 }
 
 static void particles_fluid_step(ParticleSimulationData *sim,
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index c09d3070da9..6f4ac4c44a0 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -2461,7 +2461,7 @@ int text_check_identifier_nodigit_unicode(const unsigned int ch)
 
 bool text_check_whitespace(const char ch)
 {
-  if (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n') {
+  if (ELEM(ch, ' ', '\t', '\r', '\n')) {
     return true;
   }
   return false;
diff --git a/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc b/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc
index 14db4254f70..caacbf1a2c4 100644
--- a/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc
+++ b/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc
@@ -667,7 +667,7 @@ template<typename T> void crosssegs_test()
   if (out.vert.size() == 5) {
     int v_intersect = -1;
     for (int i = 0; i < 5; i++) {
-      if (i != v0_out && i != v1_out && i != v2_out && i != v3_out) {
+      if (!ELEM(i, v0_out, v1_out, v2_out, v3_out)) {
         EXPECT_EQ(v_intersect, -1);
         v_intersect = i;
       }
diff --git a/source/blender/compositor/intern/COM_Converter.cpp b/source/blender/compositor/intern/COM_Converter.cpp
index 60676ee42b7..15a52d10071 100644
--- a/source/blender/compositor/intern/COM_Converter.cpp
+++ b/source/blender/compositor/intern/COM_Converter.cpp
@@ -116,12 +116,19 @@
 
 bool Converter::is_fast_node(bNode *b_node)
 {
-  return !(b_node->type == CMP_NODE_BLUR || b_node->type == CMP_NODE_VECBLUR ||
-           b_node->type == CMP_NODE_BILATERALBLUR || b_node->type == CMP_NODE_DEFOCUS ||
-           b_node->type == CMP_NODE_BOKEHBLUR || b_node->type == CMP_NODE_GLARE ||
-           b_node->type == CMP_NODE_DBLUR || b_node->type == CMP_NODE_MOVIEDISTORTION ||
-           b_node->type == CMP_NODE_LENSDIST || b_node->type == CMP_NODE_DOUBLEEDGEMASK ||
-           b_node->type == CMP_NODE_DILATEERODE || b_node->type == CMP_NODE_DENOISE);
+  return !ELEM(b_node->type,
+               CMP_NODE_BLUR,
+               CMP_NODE_VECBLUR,
+               CMP_NODE_BILATERALBLUR,
+               CMP_NODE_DEFOCUS,
+               CMP_NODE_BOKEHBLUR,
+               CMP_NODE_GLARE,
+               CMP_NODE_DBLUR,
+               CMP_NODE_MOVIEDISTORTION,
+               CMP_NODE_LENSDIST,
+               CMP_NODE_DOUBLEEDGEMASK,
+               CMP_NODE_DILATEERODE,
+               CMP_NODE_DENOISE);
 }
 
 Node *Converter::convert(bNode *b_node)
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 30a73afa94e..df7fd3dee0e 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -2295,7 +2295,7 @@ void uiItemFullR(uiLayout *layout,
     ui_item_enum_expand(layout, block, ptr, prop, name, h, icon_only);
   }
   /* property with separate label */


@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list