[Bf-blender-cvs] [a358f6bb692] master: Cleanup: use STR_ELEM macro

Campbell Barton noreply at git.blender.org
Wed Apr 10 09:37:06 CEST 2019


Commit: a358f6bb692b3e81c48f4ee2ef6d1ad3438f41e6
Author: Campbell Barton
Date:   Wed Apr 10 09:36:06 2019 +0200
Branches: master
https://developer.blender.org/rBa358f6bb692b3e81c48f4ee2ef6d1ad3438f41e6

Cleanup: use STR_ELEM macro

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

M	source/blender/gpu/intern/gpu_codegen.c
M	source/blender/makesdna/intern/dna_genfile.c
M	source/blender/makesrna/intern/rna_space.c
M	source/blender/nodes/composite/nodes/node_composite_scale.c
M	source/blender/python/intern/bpy_rna.c
M	source/creator/creator.c

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

diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index 0b69b0c6cd8..552ae8f4cd7 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -1349,7 +1349,7 @@ static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, const eGPUType
 		name = outnode->name;
 		input = outnode->inputs.first;
 
-		if ((STREQ(name, "set_value") || STREQ(name, "set_rgb") || STREQ(name, "set_rgba")) &&
+		if ((STR_ELEM(name, "set_value", "set_rgb", "set_rgba")) &&
 		    (input->type == type))
 		{
 			input = MEM_dupallocN(outnode->inputs.first);
diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c
index 38e1d0986fd..b31fa8e0589 100644
--- a/source/blender/makesdna/intern/dna_genfile.c
+++ b/source/blender/makesdna/intern/dna_genfile.c
@@ -38,6 +38,7 @@
 #include "BLI_utildefines.h"
 #include "BLI_endian_switch.h"
 #include "BLI_memarena.h"
+#include "BLI_string.h"
 
 #ifdef WITH_DNA_GHASH
 #  include "BLI_ghash.h"
@@ -718,17 +719,17 @@ const char *DNA_struct_get_compareflags(const SDNA *oldsdna, const SDNA *newsdna
  */
 static eSDNA_Type sdna_type_nr(const char *dna_type)
 {
-	if     ((strcmp(dna_type, "char") == 0) || (strcmp(dna_type, "const char") == 0))        { return SDNA_TYPE_CHAR; }
-	else if ((strcmp(dna_type, "uchar") == 0) || (strcmp(dna_type, "unsigned char") == 0))   { return SDNA_TYPE_UCHAR; }
-	else if ( strcmp(dna_type, "short") == 0)                                                { return SDNA_TYPE_SHORT; }
-	else if ((strcmp(dna_type, "ushort") == 0) || (strcmp(dna_type, "unsigned short") == 0)) { return SDNA_TYPE_USHORT; }
-	else if ( strcmp(dna_type, "int") == 0)                                                  { return SDNA_TYPE_INT; }
-	else if ( strcmp(dna_type, "float") == 0)                                                { return SDNA_TYPE_FLOAT; }
-	else if ( strcmp(dna_type, "double") == 0)                                               { return SDNA_TYPE_DOUBLE; }
-	else if ( strcmp(dna_type, "int64_t") == 0)                                              { return SDNA_TYPE_INT64; }
-	else if ( strcmp(dna_type, "uint64_t") == 0)                                             { return SDNA_TYPE_UINT64; }
+	if      (STR_ELEM(dna_type, "char", "const char"))           { return SDNA_TYPE_CHAR; }
+	else if (STR_ELEM(dna_type, "uchar", "unsigned char"))       { return SDNA_TYPE_UCHAR; }
+	else if (STR_ELEM(dna_type, "short"))                        { return SDNA_TYPE_SHORT; }
+	else if (STR_ELEM(dna_type, "ushort", "unsigned short"))     { return SDNA_TYPE_USHORT; }
+	else if (STR_ELEM(dna_type, "int"))                          { return SDNA_TYPE_INT; }
+	else if (STR_ELEM(dna_type, "float"))                        { return SDNA_TYPE_FLOAT; }
+	else if (STR_ELEM(dna_type, "double"))                       { return SDNA_TYPE_DOUBLE; }
+	else if (STR_ELEM(dna_type, "int64_t"))                      { return SDNA_TYPE_INT64; }
+	else if (STR_ELEM(dna_type, "uint64_t"))                     { return SDNA_TYPE_UINT64; }
 	/* invalid! */
-	else                                                                                     { return -1; }
+	else                                                         { return -1; }
 }
 
 /**
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 91a6ab96b72..bc7aaa1d97d 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -664,8 +664,7 @@ static void rna_3DViewShading_type_update(Main *bmain, Scene *scene, PointerRNA
 	View3DShading *shading = ptr->data;
 	if (shading->type == OB_MATERIAL ||
 	    (shading->type == OB_RENDER &&
-	     (strcmp(scene->r.engine, RE_engine_id_BLENDER_EEVEE) == 0 ||
-	      strcmp(scene->r.engine, RE_engine_id_CYCLES) == 0)))
+	     STR_ELEM(scene->r.engine, RE_engine_id_BLENDER_EEVEE, RE_engine_id_CYCLES)))
 	{
 		/* When switching from workbench to render or material mode the geometry of any
 		 * active sculpt session needs to be recalculated. */
diff --git a/source/blender/nodes/composite/nodes/node_composite_scale.c b/source/blender/nodes/composite/nodes/node_composite_scale.c
index a98872ea43b..4bd9b5e5db7 100644
--- a/source/blender/nodes/composite/nodes/node_composite_scale.c
+++ b/source/blender/nodes/composite/nodes/node_composite_scale.c
@@ -44,7 +44,7 @@ static void node_composite_update_scale(bNodeTree *UNUSED(ntree), bNode *node)
 
 	/* Only show X/Y scale factor inputs for modes using them! */
 	for (sock = node->inputs.first; sock; sock = sock->next) {
-		if (STREQ(sock->name, "X") || STREQ(sock->name, "Y")) {
+		if (STR_ELEM(sock->name, "X", "Y")) {
 			if (use_xy_scale) {
 				sock->flag &= ~SOCK_UNAVAIL;
 			}
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index f695464ec42..d9052aafae8 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -4136,7 +4136,7 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname)
 	}
 	else if (name[0] == '_') {  /* rna can't start with a "_", so for __dict__ and similar we can skip using rna lookups */
 		/* annoying exception, maybe we need to have different types for this... */
-		if ((STREQ(name, "__getitem__") || STREQ(name, "__setitem__")) && !RNA_struct_idprops_check(self->ptr.type)) {
+		if (STR_ELEM(name, "__getitem__", "__setitem__") && !RNA_struct_idprops_check(self->ptr.type)) {
 			PyErr_SetString(PyExc_AttributeError, "bpy_struct: no __getitem__ support for this type");
 			ret = NULL;
 		}
diff --git a/source/creator/creator.c b/source/creator/creator.c
index ad768f13e71..f44c1d1303a 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -269,9 +269,7 @@ int main(
 	{
 		int i;
 		for (i = 0; i < argc; i++) {
-			if (STREQ(argv[i], "--debug") || STREQ(argv[i], "-d") ||
-			    STREQ(argv[i], "--debug-memory") || STREQ(argv[i], "--debug-all"))
-			{
+			if (STR_ELEM(argv[i], "-d", "--debug", "--debug-memory", "--debug-all")) {
 				printf("Switching to fully guarded memory allocator.\n");
 				MEM_use_guarded_allocator();
 				break;



More information about the Bf-blender-cvs mailing list