Hi Aleksey,
On 05/03/2016 02:39 PM, Aleksey Shipilev wrote:
*) There is ever-so-subtle difference in doing either: 171 byte[] tmp = new byte[path.length + 1]; 172 System.arraycopy(path, 0, tmp, 1, path.length); 173 tmp[0] = '/'; ...or: 1083 byte[] name = new byte[nlen + 1]; 1084 name[0] = '/'; 1085 System.arraycopy(cen, pos + CENHDR, name, 1, nlen); Excess op between allocation and arraycopy breaks zeroing elimination, see e.g.: http://cr.openjdk.java.net/~shade/scratch/ZeroingFirstBench.java
...so when allocation of array is immediately followed with arraycopy where the newly allocated array is the target, only the part of the array that is not overwritten by arraycopy will be zeroed? Because not the whole array is overwritten in your example/benchmark. That's good to know.
Regards, Peter