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.

---

The fact that we returned entries that can be mutated by another `_insert()`, and that is kept alive even after we delete it from the treebuilder seems completely crazy to me. I think we should not guarantee that the entry is going to survive the next operation and ask the user to make a copy if they actually want it.