Commit 3b7f9878a38d53f15be7e33cd55c2b68d870710a

Stefan Sperling 2018-11-19T00:04:25

eliminate strlen() call in got_object_tree_path_changed()

diff --git a/lib/object.c b/lib/object.c
index 641b24f..7257f45 100644
--- a/lib/object.c
+++ b/lib/object.c
@@ -895,7 +895,7 @@ got_object_tree_path_changed(int *changed,
 	struct got_tree_object *tree1 = NULL, *tree2 = NULL;
 	struct got_tree_entry *te1 = NULL, *te2 = NULL;
 	const char *seg, *s;
-	size_t seglen, remain = strlen(path);
+	size_t seglen;
 
 	*changed = 0;
 
@@ -911,15 +911,13 @@ got_object_tree_path_changed(int *changed,
 	tree2 = tree02;
 	s = path;
 	s++; /* skip leading '/' */
-	remain--;
 	seg = s;
 	seglen = 0;
-	while (remain > 0) {
+	while (*s) {
 		struct got_tree_object *next_tree1, *next_tree2;
 
 		if (*s != '/') {
 			s++;
-			remain--;
 			seglen++;
 			if (*s)
 				continue;
@@ -947,14 +945,13 @@ got_object_tree_path_changed(int *changed,
 			goto done;
 		}
 
-		if (remain == 0) { /* final path element */
+		if (*s == '\0') { /* final path element */
 			*changed = 1;
 			goto done;
 		}
 
 		seg = s + 1;
 		s++;
-		remain--;
 		seglen = 0;
 		if (*s) {
 			err = got_object_open_as_tree(&next_tree1, repo,