RFR: 8282429: StringBuilder/StringBuffer.toString() skip compressing for UTF16 strings

Xin Liu xliu at openjdk.java.net
Thu Mar 3 02:44:15 UTC 2022


If AbstractStringBuilder only grow, the inflated value which is encoded in UTF16 can't be compressed. 
toString() can skip compression in this case. This can save an ArrayAllocation in StringUTF16::compress.

java.io.BufferedRead::readLine() is a case that StringBuilder grows only.

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

Commit messages:
 - Add a microbenchmark.
 - 8282429:  StringBuilder/StringBuffer.toString() skip compressing for UTF16 strings

Changes: https://git.openjdk.java.net/jdk/pull/7671/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=7671&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8282429
  Stats: 44 lines in 5 files changed: 37 ins; 3 del; 4 mod
  Patch: https://git.openjdk.java.net/jdk/pull/7671.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/7671/head:pull/7671

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


More information about the core-libs-dev mailing list