]> source.dussan.org Git - jgit.git/commit
Avoid TemporaryBuffer.Heap on very small deltas 07/11807/4
authorShawn Pearce <sop@google.com>
Thu, 11 Apr 2013 07:49:42 +0000 (00:49 -0700)
committerShawn Pearce <spearce@spearce.org>
Fri, 12 Apr 2013 19:07:11 +0000 (12:07 -0700)
commita5c6aac76c6f5fa19e4582bef60417647faeccf8
tree2b7e910b560e5983cf916a3bb9342fd498a2e74e
parent8a7c2f97d06df698bd8086ece4a9ade83273dd20
Avoid TemporaryBuffer.Heap on very small deltas

TemporaryBuffer is great when the output size is not known, but must
be bound by a relatively large upper limit that fits in memory, e.g.
64 KiB or 20 MiB.  The buffer gracefully supports growing storage by
allocating 8 KiB blocks and storing them in an ArrayList.

In a Git repository many deltas are less than 8 KiB.  Typical tree
objects are well below this threshold, and their deltas must be
encoded even smaller.

For these much smaller cases avoid the 8 KiB minimum allocation used
by TemporaryBuffer.  Instead allocate a very small OutputStream
writing to an array that is sized at the limit.

Change-Id: Ie25c6d3a8cf4604e0f8cd9a3b5b701a592d6ffca
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/pack/DeltaWindow.java