Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8054307 JEP 254: Compact Strings
  3. JDK-8139316

Replace common copying loops with arraycopy/copyOf/copyOfRange

XMLWordPrintable

    • Icon: Sub-task Sub-task
    • Resolution: Won't Fix
    • Icon: P4 P4
    • 9
    • None
    • core-libs
    • None

      In current implementation, we have the manual copy loops:

          @HotSpotIntrinsicCandidate
          public static byte[] toBytes(char[] value, int off, int len) {
              byte[] val = new byte[len << 1];
              for (int i = 0; i < len; i++) {
                  putChar(val, i, value[off++]);
              }
              return val;
          }

      ....

                  byte buf[] = new byte[value.length];
                  for (int j = 0; j < i; j++) {
                      putChar(buf, j, getChar(value, j)); // TBD:arraycopy?
                  }

      These can be substituted with System.arraycopy, Arrays.copyOf[Range], etc.

            shade Aleksey Shipilev
            shade Aleksey Shipilev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: