commit 4b9176646e568036623abaee94c8cff7b5e37e09 from: Stefan Sperling date: Sat Nov 17 15:34:00 2018 UTC make diff's match_entry_by_name() exit early if possible commit - d6ce02f1123a40ccc98f5dfd40168b6d8d986f95 commit + 4b9176646e568036623abaee94c8cff7b5e37e09 blob - be49c124bae5a2719cd00e9b503cad1467a5ad6e blob + af94e1b578c120937895e8cd0f7ea38a83a45705 --- lib/diff.c +++ lib/diff.c @@ -162,7 +162,13 @@ match_entry_by_name(struct got_tree_entry *te1, struct entries2 = got_object_tree_get_entries(tree2); SIMPLEQ_FOREACH(te2, &entries2->head, entry) { - if (strcmp(te1->name, te2->name) == 0) + /* Note that tree entries are sorted in strcmp() order. */ + int cmp = strcmp(te1->name, te2->name); + if (cmp < 0) + continue; + else if (cmp > 0) + break; + else return te2; } return NULL;