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

Avoid unnecessary array fill after creation in javax.swing.text

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P5 P5
    • 21
    • None
    • client-libs

      There a few places in javax.swing.text where a new array is created and then immediately filled with default values.
      1. javax.swing.text.ParagraphView.Row#layoutMajorAxis

          int[] spaceMap = new int[rowEndOffset - rowStartOffset];
          Arrays.fill(spaceMap, 0);

      2. javax.swing.text.html.TableView.ColumnIterator#updatePercentagesAndAdjustmentWeights

          adjustmentWeights = new int[columnRequirements.length];
          for (int i = 0; i < columnRequirements.length; i++) {
              adjustmentWeights[i] = 0;
          }

      It's redundant. Java guarantees that all elements of array have default values after array creation.

            aturbanov Andrey Turbanov
            aturbanov Andrey Turbanov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: