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

Avoid unnecessary array fill after creation in java.awt.image

XMLWordPrintable

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

      There a few places in java.awt.image where a new array is created and then immediately filled with default values.
      A few examples:

              int[] bandOffsets = new int[numBands];
              for (int i=0; i < numBands; i++) {
                  bandOffsets[i] = 0;
              }
              return bandOffsets;


              zpixel = new int[numComponents];
              java.util.Arrays.fill(zpixel, 0);


              byte[] bpixel = new byte[numComponents];
              for (int i = 0; i < numColorComponents; i++) {
                  bpixel[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: