[PATCH 3/3] lib: clean up _notmuch_database_split_path
Jani Nikula
jani at nikula.org
Sun Apr 10 12:43:23 PDT 2016
Make the logic it a bit easier to read. No functional changes.
---
lib/database.cc | 17 +++--------------
1 file changed, 3 insertions(+), 14 deletions(-)
diff --git a/lib/database.cc b/lib/database.cc
index b8486f7d5271..c8c5e26106ad 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -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)
--
2.1.4
More information about the notmuch
mailing list