diff options
| author | Carlos Martín Nieto <cmn@dwim.me> | 2014-06-09 04:38:22 +0200 |
|---|---|---|
| committer | Carlos Martín Nieto <cmn@dwim.me> | 2014-06-10 15:14:13 +0200 |
| commit | 4d3f1f97404b01cd00ad5b2f47f64672d787e901 (patch) | |
| tree | 3e1463a9d8fc93ad43dc10bc7034db466c4dfbc9 /src/tree.h | |
| parent | 7064cdafbd25f66de016467b381d9f4474fba40a (diff) | |
| download | libgit2-4d3f1f97404b01cd00ad5b2f47f64672d787e901.tar.gz | |
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.
Diffstat (limited to 'src/tree.h')
| -rw-r--r-- | src/tree.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/tree.h b/src/tree.h index f07039a07..38daf21d4 100644 --- a/src/tree.h +++ b/src/tree.h @@ -11,9 +11,9 @@ #include "repository.h" #include "odb.h" #include "vector.h" +#include "strmap.h" struct git_tree_entry { - uint16_t removed; uint16_t attr; git_oid oid; size_t filename_len; @@ -26,8 +26,9 @@ struct git_tree { }; struct git_treebuilder { - git_vector entries; + git_vector removed; size_t entrycount; /* vector may contain "removed" entries */ + git_strmap *map; }; GIT_INLINE(bool) git_tree_entry__is_tree(const struct git_tree_entry *e) |
