summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorShawn Pearce <sop@google.com>2014-11-25 09:58:45 -0800
committerShawn Pearce <sop@google.com>2014-11-25 10:21:48 -0800
commit4206ea43b81eadf5c3e9d80cf286968cb134a45c (patch)
tree2ebd3ace5d7649ebdcd90fb1369e948a02a22e2c /org.eclipse.jgit
parent67b8bcc1c4b50fcccbdd02be8d50a65e1484460e (diff)
downloadjgit-4206ea43b81eadf5c3e9d80cf286968cb134a45c.tar.gz
jgit-4206ea43b81eadf5c3e9d80cf286968cb134a45c.zip
Switch FileHeader.extractFileLines to TemporaryBuffer.Heap
File contents are processed into a single byte[] for character conversion. The data must fit entirely in memory, so avoid any file IO. Change-Id: I3fe8be2e5f37d5ae953596dda1ed3fe6d4f6aebc
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/patch/FileHeader.java7
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/patch/Patch.java12
2 files changed, 5 insertions, 14 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/patch/FileHeader.java b/org.eclipse.jgit/src/org/eclipse/jgit/patch/FileHeader.java
index 8171669bc8..534c827314 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/patch/FileHeader.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/patch/FileHeader.java
@@ -267,7 +267,7 @@ public class FileHeader extends DiffEntry {
final TemporaryBuffer[] tmp = new TemporaryBuffer[getParentCount() + 1];
try {
for (int i = 0; i < tmp.length; i++)
- tmp[i] = new TemporaryBuffer.LocalFile();
+ tmp[i] = new TemporaryBuffer.Heap(Integer.MAX_VALUE);
for (final HunkHeader h : getHunks())
h.extractFileLines(tmp);
@@ -281,11 +281,6 @@ public class FileHeader extends DiffEntry {
return r;
} catch (IOException ioe) {
throw new RuntimeException(JGitText.get().cannotConvertScriptToText, ioe);
- } finally {
- for (final TemporaryBuffer b : tmp) {
- if (b != null)
- b.destroy();
- }
}
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/patch/Patch.java b/org.eclipse.jgit/src/org/eclipse/jgit/patch/Patch.java
index 7b48473523..383c1f8fef 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/patch/Patch.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/patch/Patch.java
@@ -139,14 +139,10 @@ public class Patch {
}
private static byte[] readFully(final InputStream is) throws IOException {
- final TemporaryBuffer b = new TemporaryBuffer.LocalFile();
- try {
- b.copy(is);
- b.close();
- return b.toByteArray();
- } finally {
- b.destroy();
- }
+ TemporaryBuffer b = new TemporaryBuffer.Heap(Integer.MAX_VALUE);
+ b.copy(is);
+ b.close();
+ return b.toByteArray();
}
/**