From c15e539e33d85c1a67b8bc84ca4b1cbd9a5a16ee Mon Sep 17 00:00:00 2001 From: extio-de Date: Tue, 4 Feb 2025 23:36:31 +0100 Subject: [PATCH] Optimized ProxyOutputStream; --- .../de/extio/lmdatasetprep/Execution.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/extio/lmdatasetprep/Execution.java b/src/main/java/de/extio/lmdatasetprep/Execution.java index 74a748e..97dd578 100644 --- a/src/main/java/de/extio/lmdatasetprep/Execution.java +++ b/src/main/java/de/extio/lmdatasetprep/Execution.java @@ -242,30 +242,37 @@ public class Execution { private static class ProxyOutputStream extends OutputStream { - private final List streams; + private final OutputStream[] streams; ProxyOutputStream(final List streams) { - this.streams = streams; + this.streams = streams.toArray(new OutputStream[0]); } @Override public void write(final int b) throws IOException { - for (final var stream : this.streams) { - stream.write(b); + for (int i = 0; i < this.streams.length; i++) { + 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 public void flush() throws IOException { - for (final var stream : this.streams) { - stream.flush(); + for (int i = 0; i < this.streams.length; i++) { + this.streams[i].flush(); } } @Override public void close() throws IOException { - for (final var stream : this.streams) { - stream.close(); + for (int i = 0; i < this.streams.length; i++) { + this.streams[i].close(); } }