From 4d3f1f97404b01cd00ad5b2f47f64672d787e901 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Mon, 9 Jun 2014 04:38:22 +0200 Subject: treebuilder: use a map instead of vector to store the entries Finding a filename in a vector means we need to resort it every time we want to read from it, which includes every time we want to write to it as well, as we want to find duplicate keys. A hash-map fits what we want to do much more accurately, as we do not care about sorting, but just the particular filename. We still keep removed entries around, as the interface let you assume they were going to be around until the treebuilder is cleared or freed, but in this case that involves an append to a vector in the filter case, which can now fail. The only time we care about sorting is when we write out the tree, so let's make that the only time we do any sorting. --- include/git2/tree.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/git2/tree.h') diff --git a/include/git2/tree.h b/include/git2/tree.h index 56922d40b..8f1d8a089 100644 --- a/include/git2/tree.h +++ b/include/git2/tree.h @@ -354,7 +354,7 @@ typedef int (*git_treebuilder_filter_cb)( * @param filter Callback to filter entries * @param payload Extra data to pass to filter callback */ -GIT_EXTERN(void) git_treebuilder_filter( +GIT_EXTERN(int) git_treebuilder_filter( git_treebuilder *bld, git_treebuilder_filter_cb filter, void *payload); -- cgit v1.2.1