Commit 298a4a4bd4f924788066a64f5ea51616d52d1cc8

Stefan Sperling 2018-09-19T20:00:36

avoid unnecessary strlen() call in find_entry_by_name()

1
2
3
4
5
6
7
8
9
10
11
12
13
14
diff --git a/lib/object.c b/lib/object.c
index 77ebb79..0532771 100644
--- a/lib/object.c
+++ b/lib/object.c
@@ -714,8 +714,7 @@ find_entry_by_name(struct got_tree_object *tree, const char *name, size_t len)
 	struct got_tree_entry *te;
 
 	SIMPLEQ_FOREACH(te, &tree->entries.head, entry) {
-		if (strlen(te->name) == len &&
-		    strncmp(te->name, name, len) == 0)
+		if (strncmp(te->name, name, len) == 0 &&  te->name[len] == '\0')
 			return te;
 	}
 	return NULL;