Re: <Swing Dev> RFR: 8263552: Use String.valueOf() for char-to-String conversion in ObjectStreamClass

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: <Swing Dev> RFR: 8263552: Use String.valueOf() for char-to-String conversion in ObjectStreamClass

Claes Redestad-2
On Sat, 20 Feb 2021 12:17:32 GMT, Сергей Цыпанов <[hidden email]> wrote:

> This is a very simple and trivial improvement about getting rid of pointless char wrapping into array

LGTM

src/java.base/share/classes/java/io/ObjectStreamClass.java line 833:

> 831:             String fname = in.readUTF();
> 832:             String signature = ((tcode == 'L') || (tcode == '[')) ?
> 833:                 in.readTypeString() : String.valueOf(tcode);

Since the result of String.valueOf here will be equal to one of the primitive signatures strings ("I", "J", ...) (otherwise ObjectStreamField will throw an exception) it might make sense to turn this into a switch expression and simplify the whole thing. I can't tell how performance sensitive this piece of code is, though.

-------------

Marked as reviewed by redestad (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/2660