Reduce garbage allocation when using TreeWalk
We now support more efficiently resetting a TreeWalk when the
walker is using a single tree traversal from the repository.
This is very common during an ObjectWalk for a PackWriter, so
optimizing the code path is worth while. By using a special
form of reset we can avoid unnecessary temporary arrays and
also skip some loop conditional instructions.
When diving into a subtree iterator (which is also quite a
common operation in ObjectWalk) we want to reuse an idBuffer
and a WindowCursor as much as possible, ensuring that these
aren't created temporarily on the stack. This should help
to reduce the stress on the Inflater cache by allowing it
to reuse the same Inflater on each tree construction. We
also can avoid creating a temporary ObjectId by filling out
the mutable idBuffer during the repository lookup.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>