Merge branch 'rs/list-optim'

Fix a couple of "accumulate into a sorted list" to "accumulate and
then sort the list".

* rs/list-optim:
  walker: avoid quadratic list insertion in mark_complete
  sha1_name: avoid quadratic list insertion in handle_one_ref
This commit is contained in:
Junio C Hamano 2014-09-11 10:33:35 -07:00
commit 294792326a
2 changed files with 7 additions and 3 deletions

View File

@ -839,7 +839,7 @@ static int handle_one_ref(const char *path,
}
if (object->type != OBJ_COMMIT)
return 0;
commit_list_insert_by_date((struct commit *)object, list);
commit_list_insert((struct commit *)object, list);
return 0;
}
@ -1366,6 +1366,7 @@ static int get_sha1_with_context_1(const char *name,
if (!only_to_die && namelen > 2 && name[1] == '/') {
struct commit_list *list = NULL;
for_each_ref(handle_one_ref, &list);
commit_list_sort_by_date(&list);
return get_sha1_oneline(name + 2, sha1, list);
}
if (namelen < 3 ||

View File

@ -205,7 +205,7 @@ static int mark_complete(const char *path, const unsigned char *sha1, int flag,
struct commit *commit = lookup_commit_reference_gently(sha1, 1);
if (commit) {
commit->object.flags |= COMPLETE;
commit_list_insert_by_date(commit, &complete);
commit_list_insert(commit, &complete);
}
return 0;
}
@ -267,8 +267,11 @@ int walker_fetch(struct walker *walker, int targets, char **target,
goto done;
}
}
if (!walker->get_recover)
if (!walker->get_recover) {
for_each_ref(mark_complete, NULL);
commit_list_sort_by_date(&complete);
}
for (i = 0; i < targets; i++) {
if (interpret_target(walker, target[i], &sha1[20 * i])) {