]> rtime.felk.cvut.cz Git - notmuch.git/commitdiff
lib: clean up _notmuch_database_split_path
authorJani Nikula <jani@nikula.org>
Sun, 10 Apr 2016 19:43:23 +0000 (22:43 +0300)
committerDavid Bremner <david@tethera.net>
Tue, 12 Apr 2016 23:46:42 +0000 (20:46 -0300)
Make the logic it a bit easier to read. No functional changes.

lib/database.cc

index b8486f7d5271771648ef0ff1ec71c8887a43b391..c8c5e26106ad9d1086eb92ee0998d30a312dca99 100644 (file)
@@ -1761,18 +1761,11 @@ _notmuch_database_split_path (void *ctx,
     slash = path + strlen (path) - 1;
 
     /* First, skip trailing slashes. */
-    while (slash != path) {
-       if (*slash != '/')
-           break;
-
+    while (slash != path && *slash == '/')
        --slash;
-    }
 
     /* Then, find a slash. */
-    while (slash != path) {
-       if (*slash == '/')
-           break;
-
+    while (slash != path && *slash != '/') {
        if (basename)
            *basename = slash;
 
@@ -1780,12 +1773,8 @@ _notmuch_database_split_path (void *ctx,
     }
 
     /* Finally, skip multiple slashes. */
-    while (slash != path) {
-       if (*(slash - 1) != '/')
-           break;
-
+    while (slash != path && *(slash - 1) == '/')
        --slash;
-    }
 
     if (slash == path) {
        if (directory)