On Fri, 22 Sep 2023 08:53:07 GMT, Claes Redestad <[email protected]> wrote:
>> `URLEncoder` currently appends chars that needs encoding into a >> `java.io.CharArrayWriter`, converts that to a `String`, uses >> `String::getBytes` to get the encoded bytes and then appends these bytes in >> a escaped manner to the output stream. This is somewhat inefficient. >> >> This PR replaces the `CharArrayWriter` with a reusable `CharBuffer` + >> `ByteBuffer` pair. This allows us to encode to the output `StringBuilder` in >> small chunks, with greatly reduced allocation as a result. >> >> The exact size of the buffers is an open question, but generally it seems >> that a tiny buffer wins by virtue of allocating less, and that the per chunk >> overheads are relatively small. > > Claes Redestad has updated the pull request incrementally with one additional > commit since the last revision: > > Update src/java.base/share/classes/java/net/URLEncoder.java > > Co-authored-by: ExE Boss <[email protected]> How would this be an improvement? ------------- PR Comment: https://git.openjdk.org/jdk/pull/15865#issuecomment-1748302930
