summaryrefslogtreecommitdiff
path: root/src/merge.c
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2015-12-16 12:30:52 +0100
committerVicent Marti <tanoku@gmail.com>2015-12-16 12:30:52 +0100
commit879ebab314fe60cc737d436f62f190260ce13c1a (patch)
tree41d1fd8db670d5649959009eb6052da53595b932 /src/merge.c
parent7f2c1469f8565fa8809c03aa7aa0ffae90a99c66 (diff)
downloadlibgit2-879ebab314fe60cc737d436f62f190260ce13c1a.tar.gz
merge: Use `git_index__fill` to populate the indexvmg/index-fill
Instead of calling `git_index_add` in a loop, use the new `git_index_fill` internal API to fill the index with the initial staged entries. The new `fill` helper assumes that all the entries will be unique and valid, so it can append them at the end of the entries vector and only sort it once at the end. It performs no validation checks. This prevents the quadratic behavior caused by having to sort the entries list once after every insertion.
Diffstat (limited to 'src/merge.c')
-rw-r--r--src/merge.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/merge.c b/src/merge.c
index 9eb3b0904..61ff93c19 100644
--- a/src/merge.c
+++ b/src/merge.c
@@ -1739,7 +1739,6 @@ static int index_from_diff_list(git_index **out,
{
git_index *index;
size_t i;
- git_index_entry *entry;
git_merge_diff *conflict;
int error = 0;
@@ -1748,10 +1747,8 @@ static int index_from_diff_list(git_index **out,
if ((error = git_index_new(&index)) < 0)
return error;
- git_vector_foreach(&diff_list->staged, i, entry) {
- if ((error = git_index_add(index, entry)) < 0)
- goto on_error;
- }
+ if ((error = git_index__fill(index, &diff_list->staged)) < 0)
+ goto on_error;
git_vector_foreach(&diff_list->conflicts, i, conflict) {
const git_index_entry *ancestor =