Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8321059

Unneeded array assignments in MergeCollation and CompactByteArray

XMLWordPrintable

    • b27
    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      Java 22 EA

      A DESCRIPTION OF THE PROBLEM :
      In Java arrays are initialized to a value when created. Depending of the type of the array they are initialized for example to 0, 0.0, 0.0f, false or null.
      That means that they don't need to be fill with these value after creating.
      In the core library, there are 2 places where they are initialized in a big loop (more than 500 loops):
      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

      I think that at both places the array initialization can be removed as it's done in the constructor upon a private field.


      FREQUENCY : always


            naoto Naoto Sato
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: