JDK-8139316 : Replace common copying loops with arraycopy/copyOf/copyOfRange
  • Type: Sub-task
  • Component: core-libs
  • Sub-Component: java.lang
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • Submitted: 2015-10-09
  • Updated: 2015-11-06
  • Resolved: 2015-11-06
Description
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.
Comments
Closing as WNF, because using Unsafe in String code leads to bootstrapping problems.
06-11-2015