mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-10-31 17:45:58 +01:00
Fix performance issue of encrypt and sign operations by buffering
This commit is contained in:
parent
c967cbb9f0
commit
57fbb469ea
2 changed files with 12 additions and 1 deletions
|
@ -46,4 +46,10 @@ public class CRLFGeneratorStream extends OutputStream {
|
|||
}
|
||||
crlfOut.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() throws IOException {
|
||||
super.flush();
|
||||
crlfOut.flush();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
package org.pgpainless.encryption_signing;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
|
@ -182,7 +183,11 @@ public final class EncryptionStream extends OutputStream {
|
|||
}
|
||||
|
||||
public void prepareInputEncoding() {
|
||||
CRLFGeneratorStream crlfGeneratorStream = new CRLFGeneratorStream(outermostStream,
|
||||
// By buffering here, we drastically improve performance
|
||||
// Reason is that CRLFGeneratorStream only implements write(int), so we need BufferedOutputStream to
|
||||
// "convert" to write(buf) calls again
|
||||
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(outermostStream);
|
||||
CRLFGeneratorStream crlfGeneratorStream = new CRLFGeneratorStream(bufferedOutputStream,
|
||||
options.isApplyCRLFEncoding() ? StreamEncoding.UTF8 : StreamEncoding.BINARY);
|
||||
outermostStream = crlfGeneratorStream;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue