mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-19 19:02:06 +01:00
Fix performance issues of sop armor and dearmor operations
This commit is contained in:
parent
57fbb469ea
commit
9cdea63ec4
2 changed files with 9 additions and 2 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
package org.pgpainless.sop;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
@ -28,8 +29,11 @@ public class ArmorImpl implements Armor {
|
|||
return new Ready() {
|
||||
@Override
|
||||
public void writeTo(OutputStream outputStream) throws IOException {
|
||||
ArmoredOutputStream armor = ArmoredOutputStreamFactory.get(outputStream);
|
||||
// By buffering the output stream, we can improve performance drastically
|
||||
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(outputStream);
|
||||
ArmoredOutputStream armor = ArmoredOutputStreamFactory.get(bufferedOutputStream);
|
||||
Streams.pipeAll(data, armor);
|
||||
bufferedOutputStream.flush();
|
||||
armor.close();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
package org.pgpainless.sop;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
@ -22,7 +23,9 @@ public class DearmorImpl implements Dearmor {
|
|||
|
||||
@Override
|
||||
public void writeTo(OutputStream outputStream) throws IOException {
|
||||
Streams.pipeAll(decoder, outputStream);
|
||||
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(outputStream);
|
||||
Streams.pipeAll(decoder, bufferedOutputStream);
|
||||
bufferedOutputStream.flush();
|
||||
decoder.close();
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue