Skip to content

Commit 3ea743b

Browse files
author
Uwe Voigt
committed
[COMPRESS-722] Be more memory efficient when writing one byte
1 parent 5bb7daa commit 3ea743b

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,12 @@ public ZipArchiveOutputStream get() throws IOException {
180180
* and writes it to the underlying StreamCompressor as raw (already-compressed) bytes.
181181
*/
182182
private class CompressorBridgeOutputStream extends OutputStream {
183+
private final byte[] oneByte = new byte[1];
184+
183185
@Override
184186
public void write(final int b) throws IOException {
185-
final byte[] buf = { (byte) b };
186-
write(buf, 0, 1);
187+
oneByte[0] = (byte) (b & ZipConstants.BYTE_MASK);
188+
write(oneByte, 0, 1);
187189
}
188190

189191
@Override

0 commit comments

Comments
 (0)