Unneeded array assignments in core libs

Anthony Goubard anthony.goubard at gmail.com
Wed Nov 29 12:54:48 UTC 2023


Hello,

 Last Friday, I decided to look if there were some classes that did
unneeded array assignments (e.g. to 0 / 0.0f / null / false) in the JDK.

 I've found a few places and in particular 2 places where it's done in big
for loops (looping more than 500 times). So I thought you might be
interested to know about them.

https://github.com/openjdk/jdk/blob/6871a2ff1207d3ee70973b1c4ee9bd09969c185b/src/java.base/share/classes/java/text/MergeCollation.java#L72
https://github.com/openjdk/jdk/blob/6871a2ff1207d3ee70973b1c4ee9bd09969c185b/src/java.base/share/classes/sun/text/CompactByteArray.java#L85
Also for CompactByteArray, maybe it's worth checking that defaultValue is
different than 0 before entering the for loop (Line 80)

Let me know if you're interested in fixing them and if you want me to fill
2 bugs for them in the JBS or in bugreport.java.com.

Best regards,
Anthony Goubard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20231129/8083722d/attachment.htm>


More information about the core-libs-dev mailing list