diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2014-07-10 14:10:39 +0200 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-10-10 19:35:19 +0200 |
commit | 6843cebe17b7ce15eb9a6d1a88ac2e7e9c00d5b9 (patch) | |
tree | 70d5887084b1ba6e471f9f5723414cd7748575e9 /src/index.c | |
parent | 19c88310cb79153e19b93c59020b2f7c34794f6e (diff) | |
download | libgit2-6843cebe17b7ce15eb9a6d1a88ac2e7e9c00d5b9.tar.gz |
index: fill the tree cache when reading from a tree
When reading from a tree, we know what every tree is going to look like,
so we can fill in the tree cache completely, making use of the index for
modification of trees a lot quicker.
Diffstat (limited to 'src/index.c')
-rw-r--r-- | src/index.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/index.c b/src/index.c index 8ea1fd49e..be043a9bf 100644 --- a/src/index.c +++ b/src/index.c @@ -2277,6 +2277,7 @@ typedef struct read_tree_data { git_vector *old_entries; git_vector *new_entries; git_vector_cmp entry_cmp; + git_tree_cache *tree; } read_tree_data; static int read_tree_cb( @@ -2338,6 +2339,9 @@ int git_index_read_tree(git_index *index, const git_tree *tree) data.new_entries = &entries; data.entry_cmp = index->entries_search; + index->tree = NULL; + git_pool_clear(&index->tree_pool); + if (index_sort_if_needed(index, true) < 0) return -1; @@ -2358,6 +2362,10 @@ int git_index_read_tree(git_index *index, const git_tree *tree) } git_vector_free(&entries); + if (error < 0) + return error; + + error = git_tree_cache_read_tree(&index->tree, tree, &index->tree_pool); return error; } |