<i18n dev> RFR: 8274879: Replace uses of StringBuffer with StringBuilder within java.base classes

Naoto Sato naoto at openjdk.java.net
Thu Oct 7 16:52:13 UTC 2021

On Thu, 9 Sep 2021 06:50:21 GMT, Andrey Turbanov <github.com+741251+turbanoff at openjdk.org> wrote:

> StringBuffer is a legacy synchronized class. There are more modern alternatives which perform better:
> 1. Plain String concatenation should be preferred
> 2. StringBuilder is a direct replacement to StringBuffer which generally have better performance
> In [JDK-8264029](https://bugs.openjdk.java.net/browse/JDK-8264029)  I migrated only usages which were automatically detected by IDEA. It turns out there are more usages which can be migrated.

src/java.base/share/classes/java/lang/Character.java line 123:

> 121:  * than U+FFFF are called <em>supplementary character</em>s.  The Java
> 122:  * platform uses the UTF-16 representation in {@code char} arrays and
> 123:  * in the {@code String} and {@code StringBuilder} classes. In

Not sure simple replacement applies here, as `StringBuffer` still uses `UTF-16` representation. You may add `StringBuilder` as well here, but I think you might want to file a CSR to clarify.


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

More information about the i18n-dev mailing list