Commit 466d3b326f73598d70e55b9cf69805cb3026be55

Stefan Sperling 2019-08-02T16:18:38

remove redundant strlen() calls from got_path_cmp()

diff --git a/lib/path.c b/lib/path.c
index ad33152..a8c3780 100644
--- a/lib/path.c
+++ b/lib/path.c
@@ -161,17 +161,19 @@ got_path_is_child(const char *child, const char *parent, size_t parent_len)
 int
 got_path_cmp(const char *path1, const char *path2, size_t len1, size_t len2)
 {
-	size_t min_len = MIN(len1, len2);
+	size_t min_len;
 	size_t i = 0;
 
 	/* Leading directory separators are insignificant. */
-	while (path1[0] == '/')
+	while (path1[0] == '/') {
 		path1++;
-	while (path2[0] == '/')
+		len1--;
+	}
+	while (path2[0] == '/') {
 		path2++;
+		len2--;
+	}
 
-	len1 = strlen(path1);
-	len2 = strlen(path2);
 	min_len = MIN(len1, len2);
 
 	/* Skip over common prefix. */