Unneeded array assignments in core libs
Naoto Sato
naoto.sato at oracle.com
Thu Nov 30 20:57:25 UTC 2023
PR submitted. I was pleasantly surprised how quickly bugreport.java.com
turned reports into issues.
Naoto
On 11/29/23 2:18 PM, Anthony Goubard wrote:
> Thanks for the answers.
> I've created an issue in bugreport.java.com
> <https://urldefense.com/v3/__http://bugreport.java.com__;!!ACWV5N9M2RV99hQ!JCKcu40aRyRDgvMuEQNhuou6xgSdfeeSJdwHOkT-ivb09LZgK99sbe6nBMIMbf2e99-rMjcyDJqT8aKv1E1QdJm0yw$> with internal review ID : 9076287
>
> Hope that helps,
> Anthony
>
> Le mer. 29 nov. 2023 à 21:55, Roger Riggs <roger.riggs at oracle.com
> <mailto:roger.riggs at oracle.com>> a écrit :
>
> Hi Anthony,
>
> Go ahead a file a single bug (for the two cases).
> That code may have been written before Arrays.fill(...).
>
> Regards, Roger
>
> On 11/29/23 7:54 AM, Anthony Goubard wrote:
>> 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://urldefense.com/v3/__https://github.com/openjdk/jdk/blob/6871a2ff1207d3ee70973b1c4ee9bd09969c185b/src/java.base/share/classes/java/text/MergeCollation.java*L72__;Iw!!ACWV5N9M2RV99hQ!JCKcu40aRyRDgvMuEQNhuou6xgSdfeeSJdwHOkT-ivb09LZgK99sbe6nBMIMbf2e99-rMjcyDJqT8aKv1E2MTci-VQ$>
>> https://github.com/openjdk/jdk/blob/6871a2ff1207d3ee70973b1c4ee9bd09969c185b/src/java.base/share/classes/sun/text/CompactByteArray.java#L85 <https://urldefense.com/v3/__https://github.com/openjdk/jdk/blob/6871a2ff1207d3ee70973b1c4ee9bd09969c185b/src/java.base/share/classes/sun/text/CompactByteArray.java*L85__;Iw!!ACWV5N9M2RV99hQ!JCKcu40aRyRDgvMuEQNhuou6xgSdfeeSJdwHOkT-ivb09LZgK99sbe6nBMIMbf2e99-rMjcyDJqT8aKv1E3dkgxCBQ$>
>> 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
>> <https://urldefense.com/v3/__http://bugreport.java.com__;!!ACWV5N9M2RV99hQ!JCKcu40aRyRDgvMuEQNhuou6xgSdfeeSJdwHOkT-ivb09LZgK99sbe6nBMIMbf2e99-rMjcyDJqT8aKv1E1QdJm0yw$>.
>>
>> Best regards,
>> Anthony Goubard
>
More information about the core-libs-dev
mailing list