Integrated: 8314774: Optimize URLEncoder
Glavo
duke at openjdk.org
Tue Sep 19 13:52:59 UTC 2023
On Sat, 19 Aug 2023 20:57:27 GMT, Glavo <duke at openjdk.org> wrote:
> I mainly made these optimizations:
>
> * Avoid allocating `StringBuilder` when there are no characters in the URL that need to be encoded;
> * ~Implement a fast path for UTF-8.~ (Has been removed from this PR)
>
> In addition to improving performance, these optimizations also reduce temporary objects:
>
> * It no longer allocates any object when there are no characters in the URL that need to be encoded;
> * The initial size of StringBuilder is larger to avoid expansion as much as possible;
> * ~For UTF-8, the temporary `CharArrayWriter`, strings and byte arrays are no longer needed.~ (Has been removed from this PR)
>
> I also updated the tests to add more test cases.
This pull request has now been integrated.
Changeset: f25c920f
Author: Glavo <zjx001202 at gmail.com>
Committer: Claes Redestad <redestad at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/f25c920fd35972179d595bf0b0410c082ad45639
Stats: 150 lines in 2 files changed: 26 ins; 75 del; 49 mod
8314774: Optimize URLEncoder
Reviewed-by: redestad, dfuchs
-------------
PR: https://git.openjdk.org/jdk/pull/15354
More information about the net-dev
mailing list