From 07f7d55a346f0eb73a358736ce065f8c08b46452 Mon Sep 17 00:00:00 2001 From: René Scharfe Date: Mon, 25 Dec 2017 18:43:37 +0100 Subject: commit: avoid allocation in clear_commit_marks_many() Pass the entries of the commit array directly to clear_commit_marks_1() instead of adding them to a commit_list first. The function clears the commit and any first parent without allocation; only higher numbered parents are added to a list for later treatment. This change extends that optimization to clear_commit_marks_many(). Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- commit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'commit.c') diff --git a/commit.c b/commit.c index cab8d4455b..82667514bd 100644 --- a/commit.c +++ b/commit.c @@ -547,7 +547,7 @@ void clear_commit_marks_many(int nr, struct commit **commit, unsigned int mark) struct commit_list *list = NULL; while (nr--) { - commit_list_insert(*commit, &list); + clear_commit_marks_1(&list, *commit, mark); commit++; } while (list) -- cgit v1.2.3 From abc035126a58829cb7265b3ab2f2ca30312aa3b7 Mon Sep 17 00:00:00 2001 From: René Scharfe Date: Mon, 25 Dec 2017 18:44:03 +0100 Subject: commit: use clear_commit_marks_many() in remove_redundant() Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- commit.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'commit.c') diff --git a/commit.c b/commit.c index 82667514bd..9edc12f338 100644 --- a/commit.c +++ b/commit.c @@ -929,8 +929,7 @@ static int remove_redundant(struct commit **array, int cnt) if (work[j]->object.flags & PARENT1) redundant[filled_index[j]] = 1; clear_commit_marks(array[i], all_flags); - for (j = 0; j < filled; j++) - clear_commit_marks(work[j], all_flags); + clear_commit_marks_many(filled, work, all_flags); free_commit_list(common); } -- cgit v1.2.3 From 6fcec2f9aeeac6329ecf2f7084173f5b4346588b Mon Sep 17 00:00:00 2001 From: René Scharfe Date: Mon, 25 Dec 2017 18:48:34 +0100 Subject: commit: remove unused function clear_commit_marks_for_object_array() Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- commit.c | 14 -------------- commit.h | 1 - 2 files changed, 15 deletions(-) (limited to 'commit.c') diff --git a/commit.c b/commit.c index 9edc12f338..ff51c9f34a 100644 --- a/commit.c +++ b/commit.c @@ -559,20 +559,6 @@ void clear_commit_marks(struct commit *commit, unsigned int mark) clear_commit_marks_many(1, &commit, mark); } -void clear_commit_marks_for_object_array(struct object_array *a, unsigned mark) -{ - struct object *object; - struct commit *commit; - unsigned int i; - - for (i = 0; i < a->nr; i++) { - object = a->objects[i].item; - commit = lookup_commit_reference_gently(&object->oid, 1); - if (commit) - clear_commit_marks(commit, mark); - } -} - struct commit *pop_commit(struct commit_list **stack) { struct commit_list *top = *stack; diff --git a/commit.h b/commit.h index 99a3fea68d..bdf14f0a72 100644 --- a/commit.h +++ b/commit.h @@ -219,7 +219,6 @@ struct commit *pop_commit(struct commit_list **stack); void clear_commit_marks(struct commit *commit, unsigned int mark); void clear_commit_marks_many(int nr, struct commit **commit, unsigned int mark); -void clear_commit_marks_for_object_array(struct object_array *a, unsigned mark); enum rev_sort_order { -- cgit v1.2.3