You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Tibor17 <gi...@git.apache.org> on 2017/11/30 19:21:14 UTC
[GitHub] maven-surefire pull request #167: Speedup Standard Output if Tests
Github user Tibor17 commented on a diff in the pull request:
https://github.com/apache/maven-surefire/pull/167#discussion_r154174674
--- Diff: surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java ---
@@ -200,14 +200,8 @@ void sendProps()
@Override
public void writeTestOutput( byte[] buf, int off, int len, boolean stdout )
{
- byte[] header = stdout ? stdOutHeader : stdErrHeader;
- byte[] content =
- new byte[buf.length * 3 + 1]; // Hex-escaping can be up to 3 times length of a regular byte.
- int i = escapeBytesToPrintable( content, 0, buf, off, len );
- content[i++] = (byte) '\n';
- byte[] encodeBytes = new byte[header.length + i];
- System.arraycopy( header, 0, encodeBytes, 0, header.length );
- System.arraycopy( content, 0, encodeBytes, header.length, i );
+ final byte[] header = stdout ? stdOutHeader : stdErrHeader;
+ final byte[] encodeBytes = escapeBytesToPrintable( header, buf, off, len );
--- End diff --
Why it is so complex. Why you did not write the stream to `PrintStream#write(byte buf[], int off, int len)` and why you did not change `escapeBytesToPrintable` so that `header`, 'buf' would go to the method parameters and just only one array could be allocated without any copy-paste bytes?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org