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

Redundant array copy in Character.toString().

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • None
    • None
    • core-libs
    • None
    • generic
    • generic

      Several redundant array copies were adressed in JDK-4676426. It seems the one for Character.toString() was missed.

      Character.toString() is implemented by using String.valueOf(char[]) but should be implemented with String.valueOf(char) to avoid one allocation of the character array.

      Current implementation of Character.toString():

        public String toString() {
              char buf[] = {value};
              return String.valueOf(buf);
          }


      Suggested implementation:

        public String toString() {
              return String.valueOf(value);
          }

            Unassigned Unassigned
            chumer Christian Humer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: