[Bf-blender-cvs] [f38ad4c66be] master: Cleanup: replace STREQLEN with STRPREFIX for constant strings

Campbell Barton noreply at git.blender.org
Fri Nov 6 05:57:24 CET 2020


Commit: f38ad4c66bee4fd28dbfe3fa4662fb6f8eb7d1c5
Author: Campbell Barton
Date:   Fri Nov 6 15:56:03 2020 +1100
Branches: master
https://developer.blender.org/rBf38ad4c66bee4fd28dbfe3fa4662fb6f8eb7d1c5

Cleanup: replace STREQLEN with STRPREFIX for constant strings

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

M	source/blender/editors/curve/editcurve.c
M	source/blender/editors/interface/interface.c
M	source/blender/editors/space_file/fsmenu.c
M	source/blender/imbuf/intern/jpeg.c
M	source/blender/imbuf/intern/openexr/openexr_api.cpp
M	source/blender/imbuf/intern/png.c
M	source/creator/creator.c

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

diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index 4b7efe0f23c..db472c9ffa7 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -1029,10 +1029,10 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves)
    * need this to make further step with copying non-cv related curves copying
    * not touching cv's f-curves */
   LISTBASE_FOREACH_MUTABLE (FCurve *, fcu, orig_curves) {
-    if (STREQLEN(fcu->rna_path, "splines", 7)) {
+    if (STRPREFIX(fcu->rna_path, "splines")) {
       const char *ch = strchr(fcu->rna_path, '.');
 
-      if (ch && (STREQLEN(ch, ".bezier_points", 14) || STREQLEN(ch, ".points", 7))) {
+      if (ch && (STRPREFIX(ch, ".bezier_points") || STRPREFIX(ch, ".points"))) {
         fcurve_remove(adt, orig_curves, fcu);
       }
     }
@@ -1060,7 +1060,7 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves)
   /* the remainders in orig_curves can be copied back (like follow path) */
   /* (if it's not path to spline) */
   LISTBASE_FOREACH_MUTABLE (FCurve *, fcu, orig_curves) {
-    if (STREQLEN(fcu->rna_path, "splines", 7)) {
+    if (STRPREFIX(fcu->rna_path, "splines")) {
       fcurve_remove(adt, orig_curves, fcu);
     }
     else {
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index a69540613fb..4c3fd57131c 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -463,7 +463,7 @@ void ui_block_bounds_calc(uiBlock *block)
 
   /* hardcoded exception... but that one is annoying with larger safety */
   uiBut *bt = block->buttons.first;
-  int xof = (bt && STREQLEN(bt->str, "ERROR", 5)) ? 10 : 40;
+  int xof = (bt && STRPREFIX(bt->str, "ERROR")) ? 10 : 40;
 
   block->safety.xmin = block->rect.xmin - xof;
   block->safety.ymin = block->rect.ymin - xof;
diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c
index b7d47902fe8..d8556711c55 100644
--- a/source/blender/editors/space_file/fsmenu.c
+++ b/source/blender/editors/space_file/fsmenu.c
@@ -579,10 +579,10 @@ void fsmenu_read_bookmarks(struct FSMenu *fsmenu, const char *filename)
   name[0] = '\0';
 
   while (fgets(line, sizeof(line), fp) != NULL) { /* read a line */
-    if (STREQLEN(line, "[Bookmarks]", 11)) {
+    if (STRPREFIX(line, "[Bookmarks]")) {
       category = FS_CATEGORY_BOOKMARKS;
     }
-    else if (STREQLEN(line, "[Recent]", 8)) {
+    else if (STRPREFIX(line, "[Recent]")) {
       category = FS_CATEGORY_RECENT;
     }
     else if (line[0] == '!') {
diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c
index 525284bd867..38f8806d910 100644
--- a/source/blender/imbuf/intern/jpeg.c
+++ b/source/blender/imbuf/intern/jpeg.c
@@ -246,7 +246,7 @@ static boolean handle_app1(j_decompress_ptr cinfo)
       INPUT_BYTE(cinfo, neogeo[i], return false);
     }
     length = 0;
-    if (STREQLEN(neogeo, "NeoGeo", 6)) {
+    if (STRPREFIX(neogeo, "NeoGeo")) {
       struct NeoGeo_Word *neogeo_word = (struct NeoGeo_Word *)(neogeo + 6);
       ibuf_quality = neogeo_word->quality;
     }
@@ -362,7 +362,7 @@ static ImBuf *ibJpegImageFromCinfo(struct jpeg_decompress_struct *cinfo, int fla
          * That is why we need split it to the
          * common key/value here.
          */
-        if (!STREQLEN(str, "Blender", 7)) {
+        if (!STRPREFIX(str, "Blender")) {
           /*
            * Maybe the file have text that
            * we don't know "what it's", in that
diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp
index 7bb4176f4a6..08577f767e7 100644
--- a/source/blender/imbuf/intern/openexr/openexr_api.cpp
+++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp
@@ -1210,7 +1210,7 @@ void IMB_exr_read_channels(void *handle)
       "BlenderMultiChannel");
 
   /* 'previous multilayer attribute, flipped. */
-  short flip = (ta && STREQLEN(ta->value().c_str(), "Blender V2.43", 13));
+  short flip = (ta && STRPREFIX(ta->value().c_str(), "Blender V2.43"));
 
   exr_printf(
       "\nIMB_exr_read_channels\n%s %-6s %-22s "
diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c
index dbae641f707..c4fbd3f7563 100644
--- a/source/blender/imbuf/intern/png.c
+++ b/source/blender/imbuf/intern/png.c
@@ -521,7 +521,7 @@ static void imb_png_warning(png_structp UNUSED(png_ptr), png_const_charp message
    * and with new libpng it became too much picky, giving a warning on
    * the splash screen even.
    */
-  if ((G.debug & G_DEBUG) == 0 && STREQLEN(message, "iCCP", 4)) {
+  if ((G.debug & G_DEBUG) == 0 && STRPREFIX(message, "iCCP")) {
     return;
   }
   fprintf(stderr, "libpng warning: %s\n", message);
diff --git a/source/creator/creator.c b/source/creator/creator.c
index 8b64ca01650..03608b59117 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -349,7 +349,7 @@ int main(int argc,
 
 #if defined(__APPLE__) && !defined(WITH_PYTHON_MODULE) && !defined(WITH_HEADLESS)
   /* Patch to ignore argument finder gives us (PID?) */
-  if (argc == 2 && STREQLEN(argv[1], "-psn_", 5)) {
+  if (argc == 2 && STRPREFIX(argv[1], "-psn_")) {
     extern int GHOST_HACK_getFirstFile(char buf[]);
     static char firstfilebuf[512];



More information about the Bf-blender-cvs mailing list