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

Redundant array copy in Character.toString().

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • P4
    • Resolution: Fixed
    • None
    • None
    • core-libs
    • None
    • generic
    • generic

    Description

      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);
          }

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: