1
0
Fork 0
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:
Paul Schaub 2022-06-15 23:14:09 +02:00
parent 57fbb469ea
commit 9cdea63ec4
2 changed files with 9 additions and 2 deletions

View file

@ -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();
}
};

View file

@ -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();
}
};