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

Сергей Цыпанов github.com+10835776+stsypanov at openjdk.java.net
Sat Mar 13 15:56:08 UTC 2021


On Sat, 13 Mar 2021 15:18:59 GMT, Claes Redestad <redestad at openjdk.org> wrote:

>> This is a very simple and trivial improvement about getting rid of pointless char wrapping into array
>
> 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.

Hi, I'll check and add one more PR if it makes sense

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

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


More information about the swing-dev mailing list