RFR: 8300176: URLEncoder/URLDecoder static fields should be private static final
Claes Redestad
redestad at openjdk.org
Sun Jan 22 12:57:03 UTC 2023
On Fri, 20 Jan 2023 17:41:55 GMT, Darragh Clarke <duke at openjdk.org> wrote:
> Made the `static` fields `private static final`, updated the naming as well to reflect this.
>
> This meant I updated `URLDecoder` to set the `DEFAULT_ENCODING_NAME` itself since it had been previously getting it from `URLEncoder`.
>
> Since these fields are only referenced from inside the classes nothing else needed updated
This looks OK to me, though as @stsypanov notes initialization of `DEFAULT_ENCODING_NAME` can be further simplified.
There's an existing microbenchmark, `TestEncodeDecode`, that might be affected by these changes. It'd be interesting to get some data on before/after.
Pre-existing, but I'll also note that the `URLEncoder::DONT_NEED_ENCODING` could be constructed as `new BitSet(128)`: all set bits are in the ASCII range (0-127). Could be a win to trim it down.
-------------
Marked as reviewed by redestad (Reviewer).
PR: https://git.openjdk.org/jdk/pull/12122
More information about the net-dev
mailing list