Character.toString(char c) creates a new array and then calls a string
constructor that copies that array into a new array. It would be better
implemented as a direct call to String.valueOf(char) which avoids the
extra copy and extra allocation.
In addition, it would be nice if Character.toString(char) and/or
String.valueOf(char) were to memoize commonly requested single-character
strings.
constructor that copies that array into a new array. It would be better
implemented as a direct call to String.valueOf(char) which avoids the
extra copy and extra allocation.
In addition, it would be nice if Character.toString(char) and/or
String.valueOf(char) were to memoize commonly requested single-character
strings.
- relates to
-
JDK-8189375 Redundant array copy in Character.toString().
-
- Closed
-