Reduce garbage allocation when using TreeWalk
commit0147473253651eed937330f16cdc0606d12817e2
authorShawn O. Pearce <spearce@spearce.org>
Thu, 25 Dec 2008 02:11:02 +0000 (24 18:11 -0800)
committerRobin Rosenberg <robin.rosenberg@dewire.com>
Sun, 4 Jan 2009 00:01:53 +0000 (4 01:01 +0100)
tree1fe5d1912bc53455b622db87ac1ac50517edf559
parent20ee19e996ad51263120546a1bb2714b83ce3aa0
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>
org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/opt/AbstractTreeIteratorHandler.java
org.spearce.jgit/src/org/spearce/jgit/revwalk/ObjectWalk.java
org.spearce.jgit/src/org/spearce/jgit/transport/WalkFetchConnection.java
org.spearce.jgit/src/org/spearce/jgit/treewalk/AbstractTreeIterator.java
org.spearce.jgit/src/org/spearce/jgit/treewalk/CanonicalTreeParser.java
org.spearce.jgit/src/org/spearce/jgit/treewalk/TreeWalk.java