]> git.proxmox.com Git - libgit2.git/commit - src/libgit2/tree.c
treebuilder: use a map instead of vector to store the entries
authorCarlos Martín Nieto <cmn@dwim.me>
Mon, 9 Jun 2014 02:38:22 +0000 (04:38 +0200)
committerCarlos Martín Nieto <cmn@dwim.me>
Tue, 10 Jun 2014 13:14:13 +0000 (15:14 +0200)
commit4d3f1f97404b01cd00ad5b2f47f64672d787e901
tree3e1463a9d8fc93ad43dc10bc7034db466c4dfbc9
parent7064cdafbd25f66de016467b381d9f4474fba40a
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
src/tree.c
src/tree.h
tests/object/tree/write.c