> `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:

  Add comment, split long line

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/15865/files
  - new: https://git.openjdk.org/jdk/pull/15865/files/977de012..8665ae79

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=15865&range=04
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=15865&range=03-04

  Stats: 17 lines in 1 file changed: 16 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/15865.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/15865/head:pull/15865

PR: https://git.openjdk.org/jdk/pull/15865

Reply via email to