On Fri, 3 Jun 2022 16:48:46 GMT, Naoto Sato <na...@openjdk.org> wrote:

> The code path calls `String.getBytesNoRepl()`, but it blindly replaces 
> unmappable characters with replacements if the encoder is an `ArrayEncoder`. 
> Changed only to do so if `doReplace` is `true` in 
> `String.encodeWithEncoder()`.

src/java.base/share/classes/java/lang/String.java line 849:

> 847:         int en = scale(len, ce.maxBytesPerChar());
> 848:         // fastpath with ArrayEncoder implies `doReplace`.
> 849:         if (ce instanceof ArrayEncoder ae && doReplace) {

Wouldn't it be more readable (and perphaps faster) if we do check boolean flag 
first?

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

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

Reply via email to