[GitHub] maven-surefire pull request #167: Speedup Standard Output if Tests

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[GitHub] maven-surefire pull request #167: Speedup Standard Output if Tests

Tibor17-2
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: [hidden email]
For additional commands, e-mail: [hidden email]