diff options
| author | Michael Tesch <mitesch@microsoft.com> | 2016-08-09 12:23:19 -0400 |
|---|---|---|
| committer | Michael Tesch <mitesch@microsoft.com> | 2016-12-12 10:46:05 -0500 |
| commit | 87aaefe20b2e2fad8f0b8b236d1c23ce9ec5340f (patch) | |
| tree | cdb39442af47ecfd98c09342d365ac16bf6f7641 /include/git2 | |
| parent | 97e57e8770132d61ff2c36bee2de2c7ac5c9d609 (diff) | |
| download | libgit2-87aaefe20b2e2fad8f0b8b236d1c23ce9ec5340f.tar.gz | |
write_tree: use shared buffer for writing trees
The function to write trees allocates a new buffer for each tree.
This causes problems with performance when performing a lot
of actions involving writing trees, e.g. when doing many merges.
Fix the issue by instead handing in a shared buffer, which is then
re-used across the calls without having to re-allocate between
calls.
Diffstat (limited to 'include/git2')
| -rw-r--r-- | include/git2/tree.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/git2/tree.h b/include/git2/tree.h index 2e4735c4b..a38215f9f 100644 --- a/include/git2/tree.h +++ b/include/git2/tree.h @@ -375,6 +375,19 @@ GIT_EXTERN(void) git_treebuilder_filter( GIT_EXTERN(int) git_treebuilder_write( git_oid *id, git_treebuilder *bld); +/** + * Write the contents of the tree builder as a tree object + * using a shared git_buf. + * + * @see git_treebuilder_write + * + * @param id Pointer to store the OID of the newly written tree + * @param bld Tree builder to write + * @param tree Shared buffer for writing the tree. Will be grown as necessary. + * @return 0 or an error code + */ +GIT_EXTERN(int) git_treebuilder_write_with_buffer( + git_oid *oid, git_treebuilder *bld, git_buf *tree); /** Callback for the tree traversal method */ typedef int (*git_treewalk_cb)( |
