8377939: Improving efficiency of StreamEncoder::append(CharSequence) and StreamEncoder::(CharSequence, int, int)
Markus KARG
markus at headcrashing.eu
Sat Feb 21 16:32:30 UTC 2026
Core-Lib Devs,
as proposed in https://bugs.openjdk.org/browse/JDK-8377939 I would like
to improve efficiency of StreamEncoder::append(CharSequence) (and in
turn OutputStreamWriter::append(CharSequence)) for non-String and
non-CharBuffer values, which seems to be safe and simple:
* No API or behavior is changed.
* StreamEncoder is final and is only used internally of OpenJDK, and is
not leaked.
* AFAIK the proposed change has no side effects other than being
potentially more efficient.
* Only few classes make actual use of StreamEncoder; OutputStreamWriter
is probably the most popular one, and immediately provides potential
benefit to I/O-bound applications dealing with StringBuilder-crafted output.
I have meanwhile coded the change (see diff at
https://github.com/openjdk/jdk/compare/master...mkarg:jdk:StreamEncoder-uses-CharsSequence-getChars)
and tested it successfully using OpenJDK Github Actions (see result at
https://github.com/mkarg/jdk/actions/runs/22259626078).
Are you fine with me opening a Pull Request on Github?
Thanks!
-Markus
More information about the core-libs-dev
mailing list