On Tue, 7 Feb 2023 13:30:35 GMT, Claes Redestad <redes...@openjdk.org> wrote:

> This patch adds special-cases to `Arrays.copyOf` and `Arrays.copyOfRange` to 
> copy arrays more efficiently when exactly the whole input array is to be 
> copied. This helps eliminate range checks and has been verified to help 
> various String operations. Example:
> 
> Baseline
> 
> Benchmark                                            (size)  Mode  Cnt   
> Score   Error  Units
> StringConstructor.newStringFromArray                      7  avgt   15  
> 16.817 ± 0.369  ns/op
> StringConstructor.newStringFromArrayWithCharset           7  avgt   15  
> 16.866 ± 0.449  ns/op
> StringConstructor.newStringFromArrayWithCharsetName       7  avgt   15  
> 22.198 ± 0.396  ns/op
> 
> Patch: 
> 
> Benchmark                                            (size)  Mode  Cnt   
> Score   Error  Units
> StringConstructor.newStringFromArray                      7  avgt   15  
> 14.666 ± 0.336  ns/op
> StringConstructor.newStringFromArrayWithCharset           7  avgt   15  
> 14.582 ± 0.288  ns/op
> StringConstructor.newStringFromArrayWithCharsetName       7  avgt   15  
> 20.339 ± 0.328  ns/op

This pull request has now been integrated.

Changeset: 1f9c110c
Author:    Claes Redestad <redes...@openjdk.org>
URL:       
https://git.openjdk.org/jdk/commit/1f9c110c1f9ea6f5c3621a25692ce9d7abf245d4
Stats:     209 lines in 2 files changed: 179 ins; 21 del; 9 mod

8301958: Reduce Arrays.copyOf/-Range overheads

Reviewed-by: alanb, smarks

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

PR: https://git.openjdk.org/jdk/pull/12453

Reply via email to