eliminate strlen() call in got_object_tree_path_changed()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
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,