Aligned with spring-projects/spring-boot#12160, let's revisit all the Collection.toArray call in the codebase and consistently use the toArray(new T[0]) pattern over pre-initialized arrays with a given length. In contrast to the established latter pattern, the former turns out to be more performant on modern JVMs since it doesn't initialize the array with null values first and allows for using efficient array cloning mechanisms underneath.
We're also consistently using StringUtils.toStringArray and ClassUtils.toClassArray across the codebase now, as shortcuts with improved readability. ClassUtils.toClassArray was missed in the nullability revision and got aligned as a non-null variant a la StringUtils.toStringArray now.
Juergen Hoeller opened SPR-16523 and commented
Aligned with spring-projects/spring-boot#12160, let's revisit all the
Collection.toArray
call in the codebase and consistently use thetoArray(new T[0])
pattern over pre-initialized arrays with a given length. In contrast to the established latter pattern, the former turns out to be more performant on modern JVMs since it doesn't initialize the array withnull
values first and allows for using efficient array cloning mechanisms underneath.Affects: 5.0.4
Issue Links:
Referenced from: commits a5cbf5f
The text was updated successfully, but these errors were encountered: