summaryrefslogtreecommitdiff
path: root/src/index.c
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2015-12-16 19:36:50 +0100
committerVicent Marti <tanoku@gmail.com>2015-12-16 19:36:50 +0100
commitef8b7febc5624c265201400001e3d654dea96d83 (patch)
tree1f909a4e223fd87a2c62e1d7fdbf61fee6ca7728 /src/index.c
parentd7d46cfbfd19983ee71b53607abcaf55872be83a (diff)
downloadlibgit2-ef8b7febc5624c265201400001e3d654dea96d83.tar.gz
index: Also size-hint the hash tablevmg/index-fill-2
Note that we're not checking whether the resize succeeds; in OOM cases, we let it run with a "small" vector and hash table and see if by chance we can grow it dynamically as we insert the new entries. Nothing to lose really.
Diffstat (limited to 'src/index.c')
-rw-r--r--src/index.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/index.c b/src/index.c
index 03873f427..5c7bd90dd 100644
--- a/src/index.c
+++ b/src/index.c
@@ -1564,10 +1564,8 @@ int git_index__fill(git_index *index, const git_vector *source_entries)
return -1;
}
- if (git_vector_size_hint(&index->entries, source_entries->length) < 0) {
- git_mutex_unlock(&index->lock);
- return -1;
- }
+ git_vector_size_hint(&index->entries, source_entries->length);
+ git_idxmap_resize(index->entries_map, source_entries->length * 1.3);
git_vector_foreach(source_entries, i, source_entry) {
git_index_entry *entry = NULL;