Commit: d3ee995eafa9640bad51f6bb0c3f69b6d6aca4e6
Author: Sybren A. Stüvel
Date:   Wed Mar 20 13:39:27 2019 +0100
Branches: master
https://developer.blender.org/rBd3ee995eafa9640bad51f6bb0c3f69b6d6aca4e6

Cleanup: return early in BLI_path_frame_get

Instead of making the entire body of the function conditional, it now
returns early, unindenting the entire function and preventing the reader
from searching for a non-existent `else` clause.

No semantic changes.

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

M       source/blender/blenlib/intern/path_util.c

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

diff --git a/source/blender/blenlib/intern/path_util.c 
b/source/blender/blenlib/intern/path_util.c
index 6d69f29a228..34fb7112789 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -864,47 +864,49 @@ bool BLI_path_frame_get(char *path, int *r_frame, int 
*r_numdigits)
 
 void BLI_path_frame_strip(char *path, char *r_ext)
 {
-       if (*path) {
-               char *file = (char *)BLI_last_slash(path);
-               char *c, *suffix;
-               int len;
-               int numdigits = 0;
-
-               if (file == NULL)
-                       file = path;
+       if (*path == '\0') {
+               return;
+       }
 
-               /* first get the extension part */
-               len = strlen(file);
+       char *file = (char *)BLI_last_slash(path);
+       char *c, *suffix;
+       int len;
+       int numdigits = 0;
 
-               c = file + len;
+       if (file == NULL)
+               file = path;
 
-               /* isolate extension */
-               while (--c != file) {
-                       if (*c == '.') {
-                               c--;
-                               break;
-                       }
-               }
+       /* first get the extension part */
+       len = strlen(file);
 
-               suffix = c + 1;
+       c = file + len;
 
-               /* find start of number */
-               while (c != (file - 1) && isdigit(*c)) {
+       /* isolate extension */
+       while (--c != file) {
+               if (*c == '.') {
                        c--;
-                       numdigits++;
+                       break;
                }
+       }
 
-               c++;
+       suffix = c + 1;
 
-               int suffix_length = len - (suffix - file);
-               BLI_strncpy(r_ext, suffix, suffix_length+1);
+       /* find start of number */
+       while (c != (file - 1) && isdigit(*c)) {
+               c--;
+               numdigits++;
+       }
 
-               /* replace the number with the suffix and terminate the string 
*/
-               while (numdigits--) {
-                       *c++ = '#';
-               }
-               *c = '\0';
+       c++;
+
+       int suffix_length = len - (suffix - file);
+       BLI_strncpy(r_ext, suffix, suffix_length+1);
+
+       /* replace the number with the suffix and terminate the string */
+       while (numdigits--) {
+               *c++ = '#';
        }
+       *c = '\0';
 }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to