aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2014-03-08 12:39:50 +0200
committerLasse Collin <lasse.collin@tukaani.org>2014-03-08 12:39:50 +0200
commit9ee0c10a02479e32ce4d7dc254e7b0e32a397f3f (patch)
tree39698b5946d66e56c57a31512102a2319061d856 /src
parenta8939627fed698dea0f790ef658998ff82b3f29a (diff)
downloadxz-java-9ee0c10a02479e32ce4d7dc254e7b0e32a397f3f.tar.gz
Rename tmpbuf to filterBuf.
In the commit a9bf23ff908ac7f8f4df25fd621e04e187425a7d the field tempBuf was added to many classes. Three classes already had tmpbuf and TMPBUF_SIZE fields which sound too similar, so it's good to rename them.
Diffstat (limited to 'src')
-rw-r--r--src/org/tukaani/xz/DeltaOutputStream.java20
-rw-r--r--src/org/tukaani/xz/SimpleInputStream.java25
-rw-r--r--src/org/tukaani/xz/SimpleOutputStream.java28
3 files changed, 37 insertions, 36 deletions
diff --git a/src/org/tukaani/xz/DeltaOutputStream.java b/src/org/tukaani/xz/DeltaOutputStream.java
index 332fd8f..bd880db 100644
--- a/src/org/tukaani/xz/DeltaOutputStream.java
+++ b/src/org/tukaani/xz/DeltaOutputStream.java
@@ -13,11 +13,11 @@ import java.io.IOException;
import org.tukaani.xz.delta.DeltaEncoder;
class DeltaOutputStream extends FinishableOutputStream {
- private static final int TMPBUF_SIZE = 4096;
+ private static final int FILTER_BUF_SIZE = 4096;
private FinishableOutputStream out;
private final DeltaEncoder delta;
- private final byte[] tmpbuf = new byte[TMPBUF_SIZE];
+ private final byte[] filterBuf = new byte[FILTER_BUF_SIZE];
private boolean finished = false;
private IOException exception = null;
@@ -25,7 +25,7 @@ class DeltaOutputStream extends FinishableOutputStream {
private final byte[] tempBuf = new byte[1];
static int getMemoryUsage() {
- return 1 + TMPBUF_SIZE / 1024;
+ return 1 + FILTER_BUF_SIZE / 1024;
}
DeltaOutputStream(FinishableOutputStream out, DeltaOptions options) {
@@ -49,15 +49,15 @@ class DeltaOutputStream extends FinishableOutputStream {
throw new XZIOException("Stream finished");
try {
- while (len > TMPBUF_SIZE) {
- delta.encode(buf, off, TMPBUF_SIZE, tmpbuf);
- out.write(tmpbuf);
- off += TMPBUF_SIZE;
- len -= TMPBUF_SIZE;
+ while (len > FILTER_BUF_SIZE) {
+ delta.encode(buf, off, FILTER_BUF_SIZE, filterBuf);
+ out.write(filterBuf);
+ off += FILTER_BUF_SIZE;
+ len -= FILTER_BUF_SIZE;
}
- delta.encode(buf, off, len, tmpbuf);
- out.write(tmpbuf, 0, len);
+ delta.encode(buf, off, len, filterBuf);
+ out.write(filterBuf, 0, len);
} catch (IOException e) {
exception = e;
throw e;
diff --git a/src/org/tukaani/xz/SimpleInputStream.java b/src/org/tukaani/xz/SimpleInputStream.java
index 669f280..afd40c7 100644
--- a/src/org/tukaani/xz/SimpleInputStream.java
+++ b/src/org/tukaani/xz/SimpleInputStream.java
@@ -14,12 +14,12 @@ import java.io.IOException;
import org.tukaani.xz.simple.SimpleFilter;
class SimpleInputStream extends InputStream {
- private static final int TMPBUF_SIZE = 4096;
+ private static final int FILTER_BUF_SIZE = 4096;
private InputStream in;
private final SimpleFilter simpleFilter;
- private final byte[] tmpbuf = new byte[TMPBUF_SIZE];
+ private final byte[] filterBuf = new byte[FILTER_BUF_SIZE];
private int pos = 0;
private int filtered = 0;
private int unfiltered = 0;
@@ -30,7 +30,7 @@ class SimpleInputStream extends InputStream {
private final byte[] tempBuf = new byte[1];
static int getMemoryUsage() {
- return 1 + TMPBUF_SIZE / 1024;
+ return 1 + FILTER_BUF_SIZE / 1024;
}
SimpleInputStream(InputStream in, SimpleFilter simpleFilter) {
@@ -70,18 +70,18 @@ class SimpleInputStream extends InputStream {
while (true) {
// Copy filtered data into the caller-provided buffer.
int copySize = Math.min(filtered, len);
- System.arraycopy(tmpbuf, pos, buf, off, copySize);
+ System.arraycopy(filterBuf, pos, buf, off, copySize);
pos += copySize;
filtered -= copySize;
off += copySize;
len -= copySize;
size += copySize;
- // If end of tmpbuf was reached, move the pending data to
+ // If end of filterBuf was reached, move the pending data to
// the beginning of the buffer so that more data can be
- // copied into tmpbuf on the next loop iteration.
- if (pos + filtered + unfiltered == TMPBUF_SIZE) {
- System.arraycopy(tmpbuf, pos, tmpbuf, 0,
+ // copied into filterBuf on the next loop iteration.
+ if (pos + filtered + unfiltered == FILTER_BUF_SIZE) {
+ System.arraycopy(filterBuf, pos, filterBuf, 0,
filtered + unfiltered);
pos = 0;
}
@@ -92,8 +92,9 @@ class SimpleInputStream extends InputStream {
assert filtered == 0;
// Get more data into the temporary buffer.
- int inSize = TMPBUF_SIZE - (pos + filtered + unfiltered);
- inSize = in.read(tmpbuf, pos + filtered + unfiltered, inSize);
+ int inSize = FILTER_BUF_SIZE - (pos + filtered + unfiltered);
+ inSize = in.read(filterBuf, pos + filtered + unfiltered,
+ inSize);
if (inSize == -1) {
// Mark the remaining unfiltered bytes to be ready
@@ -102,9 +103,9 @@ class SimpleInputStream extends InputStream {
filtered = unfiltered;
unfiltered = 0;
} else {
- // Filter the data in tmpbuf.
+ // Filter the data in filterBuf.
unfiltered += inSize;
- filtered = simpleFilter.code(tmpbuf, pos, unfiltered);
+ filtered = simpleFilter.code(filterBuf, pos, unfiltered);
assert filtered <= unfiltered;
unfiltered -= filtered;
}
diff --git a/src/org/tukaani/xz/SimpleOutputStream.java b/src/org/tukaani/xz/SimpleOutputStream.java
index 7d1cc58..771b1fb 100644
--- a/src/org/tukaani/xz/SimpleOutputStream.java
+++ b/src/org/tukaani/xz/SimpleOutputStream.java
@@ -13,12 +13,12 @@ import java.io.IOException;
import org.tukaani.xz.simple.SimpleFilter;
class SimpleOutputStream extends FinishableOutputStream {
- private static final int TMPBUF_SIZE = 4096;
+ private static final int FILTER_BUF_SIZE = 4096;
private FinishableOutputStream out;
private final SimpleFilter simpleFilter;
- private final byte[] tmpbuf = new byte[TMPBUF_SIZE];
+ private final byte[] filterBuf = new byte[FILTER_BUF_SIZE];
private int pos = 0;
private int unfiltered = 0;
@@ -28,7 +28,7 @@ class SimpleOutputStream extends FinishableOutputStream {
private final byte[] tempBuf = new byte[1];
static int getMemoryUsage() {
- return 1 + TMPBUF_SIZE / 1024;
+ return 1 + FILTER_BUF_SIZE / 1024;
}
SimpleOutputStream(FinishableOutputStream out,
@@ -56,21 +56,21 @@ class SimpleOutputStream extends FinishableOutputStream {
throw new XZIOException("Stream finished or closed");
while (len > 0) {
- // Copy more unfiltered data into tmpbuf.
- int copySize = Math.min(len, TMPBUF_SIZE - (pos + unfiltered));
- System.arraycopy(buf, off, tmpbuf, pos + unfiltered, copySize);
+ // Copy more unfiltered data into filterBuf.
+ int copySize = Math.min(len, FILTER_BUF_SIZE - (pos + unfiltered));
+ System.arraycopy(buf, off, filterBuf, pos + unfiltered, copySize);
off += copySize;
len -= copySize;
unfiltered += copySize;
- // Filter the data in tmpbuf.
- int filtered = simpleFilter.code(tmpbuf, pos, unfiltered);
+ // Filter the data in filterBuf.
+ int filtered = simpleFilter.code(filterBuf, pos, unfiltered);
assert filtered <= unfiltered;
unfiltered -= filtered;
// Write out the filtered data.
try {
- out.write(tmpbuf, pos, filtered);
+ out.write(filterBuf, pos, filtered);
} catch (IOException e) {
exception = e;
throw e;
@@ -78,11 +78,11 @@ class SimpleOutputStream extends FinishableOutputStream {
pos += filtered;
- // If end of tmpbuf was reached, move the pending unfiltered
+ // If end of filterBuf was reached, move the pending unfiltered
// data to the beginning of the buffer so that more data can
- // be copied into tmpbuf on the next loop iteration.
- if (pos + unfiltered == TMPBUF_SIZE) {
- System.arraycopy(tmpbuf, pos, tmpbuf, 0, unfiltered);
+ // be copied into filterBuf on the next loop iteration.
+ if (pos + unfiltered == FILTER_BUF_SIZE) {
+ System.arraycopy(filterBuf, pos, filterBuf, 0, unfiltered);
pos = 0;
}
}
@@ -95,7 +95,7 @@ class SimpleOutputStream extends FinishableOutputStream {
throw exception;
try {
- out.write(tmpbuf, pos, unfiltered);
+ out.write(filterBuf, pos, unfiltered);
} catch (IOException e) {
exception = e;
throw e;