summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2010-05-15 16:18:44 -0700
committerShawn O. Pearce <spearce@spearce.org>2010-05-15 16:18:44 -0700
commit9c4d42e94dbf199a9cef46a4b9286552c8633f4f (patch)
tree37d4d5caaa895863153da095649416b406e2ce7b /org.eclipse.jgit
parentd8f20745bfe781116acd42c53c6a974439abde80 (diff)
downloadjgit-9c4d42e94dbf199a9cef46a4b9286552c8633f4f.tar.gz
jgit-9c4d42e94dbf199a9cef46a4b9286552c8633f4f.zip
Factor out duplicate Inflater setup in WindowCursor
Since we use this code twice, pull it into a private method. Let the compiler/JIT worry about whether or not this logic should be inlined into the call sites. Change-Id: Ia44fb01e0328485bcdfd7af96835d62b227a0fb1 Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/WindowCursor.java17
1 files changed, 9 insertions, 8 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/WindowCursor.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/WindowCursor.java
index 93e2a02420..968c92e5ce 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/WindowCursor.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/WindowCursor.java
@@ -116,10 +116,7 @@ public final class WindowCursor {
*/
int inflate(final PackFile pack, long position, final byte[] dstbuf,
int dstoff) throws IOException, DataFormatException {
- if (inf == null)
- inf = InflaterCache.get();
- else
- inf.reset();
+ prepareInflater();
for (;;) {
pin(pack, position);
dstoff = window.inflate(position, dstbuf, dstoff, inf);
@@ -131,10 +128,7 @@ public final class WindowCursor {
void inflateVerify(final PackFile pack, long position)
throws IOException, DataFormatException {
- if (inf == null)
- inf = InflaterCache.get();
- else
- inf.reset();
+ prepareInflater();
for (;;) {
pin(pack, position);
window.inflateVerify(position, inf);
@@ -144,6 +138,13 @@ public final class WindowCursor {
}
}
+ private void prepareInflater() {
+ if (inf == null)
+ inf = InflaterCache.get();
+ else
+ inf.reset();
+ }
+
private void pin(final PackFile pack, final long position)
throws IOException {
final ByteWindow w = window;