From 6843cebe17b7ce15eb9a6d1a88ac2e7e9c00d5b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Thu, 10 Jul 2014 14:10:39 +0200 Subject: 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. --- src/index.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/index.c') 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; } -- cgit v1.2.1