Optimized ProxyOutputStream;

This commit is contained in:
extio-de
2025-02-04 23:36:31 +01:00
parent 6e7db0c6d8
commit c15e539e33

View File

@@ -242,30 +242,37 @@ public class Execution {
private static class ProxyOutputStream extends OutputStream { private static class ProxyOutputStream extends OutputStream {
private final List<OutputStream> streams; private final OutputStream[] streams;
ProxyOutputStream(final List<OutputStream> streams) { ProxyOutputStream(final List<OutputStream> streams) {
this.streams = streams; this.streams = streams.toArray(new OutputStream[0]);
} }
@Override @Override
public void write(final int b) throws IOException { public void write(final int b) throws IOException {
for (final var stream : this.streams) { for (int i = 0; i < this.streams.length; i++) {
stream.write(b); this.streams[i].write(b);
}
}
@Override
public void write(final byte[] b) throws IOException {
for (int i = 0; i < this.streams.length; i++) {
this.streams[i].write(b);
} }
} }
@Override @Override
public void flush() throws IOException { public void flush() throws IOException {
for (final var stream : this.streams) { for (int i = 0; i < this.streams.length; i++) {
stream.flush(); this.streams[i].flush();
} }
} }
@Override @Override
public void close() throws IOException { public void close() throws IOException {
for (final var stream : this.streams) { for (int i = 0; i < this.streams.length; i++) {
stream.close(); this.streams[i].close();
} }
} }