mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-09 19:58:09 +00:00
index: fill the tree cache on write-tree
An obvious place to fill the tree cache is on write-tree, as we're guaranteed to be able to fill in the whole tree cache. The way this commit does this is not the most efficient, as we read the root tree from the odb instead of filling in the cache as we go along, but it fills the cache such that successive operations (and persisting the index to disk) will be able to take advantage of the cache, and it reuses the code we already have for filling the cache. Filling in the cache as we create the trees would require some reallocation of the children vector, which is currently not possible with out pool implementation. A different data structure would likely allow us to perform this operation at a later date.
This commit is contained in:
parent
795d8e9328
commit
7465e87399
17
src/tree.c
17
src/tree.c
@ -579,6 +579,7 @@ int git_tree__write_index(
|
||||
git_oid *oid, git_index *index, git_repository *repo)
|
||||
{
|
||||
int ret;
|
||||
git_tree *tree;
|
||||
bool old_ignore_case = false;
|
||||
|
||||
assert(oid && index && repo);
|
||||
@ -609,7 +610,21 @@ int git_tree__write_index(
|
||||
if (old_ignore_case)
|
||||
git_index__set_ignore_case(index, true);
|
||||
|
||||
return ret < 0 ? ret : 0;
|
||||
index->tree = NULL;
|
||||
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
git_pool_clear(&index->tree_pool);
|
||||
|
||||
if ((ret = git_tree_lookup(&tree, repo, oid)) < 0)
|
||||
return ret;
|
||||
|
||||
/* Read the tree cache into the index */
|
||||
ret = git_tree_cache_read_tree(&index->tree, tree, &index->tree_pool);
|
||||
git_tree_free(tree);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int git_treebuilder_create(git_treebuilder **builder_p, const git_tree *source)
|
||||
|
Loading…
Reference in New Issue
Block a user