Reduce the number of temporary byte[20] arrays allocated.
commit8476d83438651a1c42bb4fd673800285b9f94462
authorShawn O. Pearce <spearce@spearce.org>
Sun, 3 Dec 2006 04:44:00 +0000 (2 23:44 -0500)
committerShawn O. Pearce <spearce@spearce.org>
Sun, 3 Dec 2006 04:44:00 +0000 (2 23:44 -0500)
tree9b295549b79b012155c51db4ab3051746d8c1c5d
parent9dabf2fc594d583da597dd6fbba7b4ba1d13e241
Reduce the number of temporary byte[20] arrays allocated.

While searching for and loading an object from a pack file we were
allocating two 20 byte arrays: one to store the temporary object id
during index searching and another to store the variable length header
data (as well as an OBJ_REF) during object fetching.  But we can easily
combine these two together to reduce the amount of garbage we need to
load onto the heap.

When searching multiple pack files for an object we can easily share
the same byte[20] array across all of them by passing it down as a
parameter until one of the packs returns with the desired object.
This reduces the amount of garbage we generate when there is more
than one pack file open.  But it also complicates the API a little
and isn't very "Java like" so we should document this odd behavior.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
org.spearce.jgit/src/org/spearce/jgit/lib/DeltaRefPackedObjectLoader.java
org.spearce.jgit/src/org/spearce/jgit/lib/PackFile.java
org.spearce.jgit/src/org/spearce/jgit/lib/Repository.java
org.spearce.jgit/tst/org/spearce/jgit/lib/T0004_PackReader.java