aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm/.settings/org.eclipse.jdt.core.prefs
diff options
context:
space:
mode:
authorDave Borowitz <dborowitz@google.com>2015-03-18 11:04:26 -0700
committerDave Borowitz <dborowitz@google.com>2015-03-18 13:38:57 -0700
commitedf4368b0c29e25bb74ec0e8f12070582a580eea (patch)
tree31d0bf5fbaf5f4cd3b9cf44f0907c026bf79dd1d /org.eclipse.jgit.pgm/.settings/org.eclipse.jdt.core.prefs
parent89b91ad40677c7048d31925986e48150e975bcce (diff)
downloadjgit-edf4368b0c29e25bb74ec0e8f12070582a580eea.tar.gz
jgit-edf4368b0c29e25bb74ec0e8f12070582a580eea.zip
TemporaryBuffer: Allow presizing block pointer list
Callers may wish to use TemporaryBuffer as an essentially unbounded buffer by passing Integer.MAX_VALUE as the size. (This makes it behave like ByteArrayOutputStream, only without requiring contiguous memory.) Unfortunately, it was always allocating an array in the backing block pointer list to hold enough blocks to MAX_VALUE--all 262,016 of them. It wasn't allocating the blocks themselves, but this array was still extremely wasteful, using about 2MiB of memory on a 64-bit system. Tweak the interface to specify an estimated size, and only allocate the block pointer list enough entries to hold that size. It's an ArrayList, so if that estimate was wrong, it'll grow. We assume the cost of finding enough contiguous memory to grow that array is acceptable. While we're in there, fix an off-by-one error: due to integer division we were undercounting the number of blocks needed to store n bytes of data as (n / SZ). Change-Id: I794eca3ac4472bcc605b3641e177922aca92b9c0
Diffstat (limited to 'org.eclipse.jgit.pgm/.settings/org.eclipse.jdt.core.prefs')
0 files changed, 0 insertions, 0 deletions