Johan Herland [off-list ref] wrote:
BTW, while we're on the topic, this whole code is only present because I
assume it's not possible to edit the fast-import tree structure _while_
traversing it. Is this assumption correct, or are there ways to get
around maintaining a separate edit list that is applied to the tree
structure afterwards?
IIRC you can actually edit the tree while you are walking through it.
You just have to watch out for the fact that a struct tree_content
can be reallocated (and thus moved in memory) if the entry_capacity
was too small for the new entry_count when inserting a new entry.
tree_content_set() handles this in its API by taking a struct
tree_entry* rather than a struct tree_content*. This way if the
tree has to expand during the set and gets reallocated we can return
the new tree pointer to the caller through the struct tree_entry
tree field.
--
Shawn.