On Thu, 16 May 2024 02:37:02 GMT, Ioi Lam <ik...@openjdk.org> wrote:

> JavacBench is a test program that compiles 90 Java source files. It uses a 
> fair amount of invokedynamic callsites, so it's good for testing CDS support 
> for indy and lambda expressions.
> 
> This test was first integrated into the 
> [leyden](https://github.com/openjdk/leyden/tree/premain) repo. Hence some of 
> the files have copyrights in 2023.

test/lib/jdk/test/lib/StringArrayUtils.java line 33:

> 31:     }
> 32: 
> 33:     public static String[] concat(String prefix[], String... extra) {

Suggestion:

    public static String[] concat(String[] prefix, String... extra) {

test/lib/jdk/test/lib/StringArrayUtils.java line 42:

> 40:         }
> 41: 
> 42:         return list.toArray(new String[list.size()]);

I thought we have been preferring ot use `new String[0]` for toArray calls. 
Also for simplicity, we can change the implementation to:

var list = new ArrayList<>(Arrays.asList(prefix));
Collections.addAll(list, extra);
return list.toArray(new String[0]);

or for performance:

String[] ret = new String[prefix.length + extra.length];
System.arraycopy(prefix, 0, ret, 0, prefix.length);
System.arraycopy(extra, 0, ret, prefix.length, extra.length);
return ret;

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/19256#discussion_r1602560570
PR Review Comment: https://git.openjdk.org/jdk/pull/19256#discussion_r1602561754

Reply via email to