RFR: 8259842: Remove Result cache from StringCoding [v5]

Peter Levart plevart at openjdk.java.net
Sun Jan 17 15:55:33 UTC 2021

On Sun, 17 Jan 2021 14:56:40 GMT, Peter Levart <plevart at openjdk.org> wrote:

>> Claes Redestad has updated the pull request incrementally with one additional commit since the last revision:
>>   Simplify lookupCharset
> This looks good.
> Are you planning to do similar things for encoding too?

I already approved the changes and they are OK. Maybe for a followup: just noticing after the fact that logic for `newStringUTF8NoRepl(....)` vs. `new String(...., StringCoding.UTF_8)` differ in handling unmappabale characters, which is by the spec, but also the constructor contains special handling of input that only contains non-negative bytes:

        if (charset == UTF_8) {
            if (COMPACT_STRINGS && !StringCoding.hasNegatives(bytes, offset, length)) {
                this.value = Arrays.copyOfRange(bytes, offset, offset + length);
                this.coder = LATIN1;

...while `newStringUTF8NoRepl(....)` does not contain this optimization. I guess ZipCoder could benefit from that optimization too since paths are mostly ASCII only. So WDYT of this additional simplification/consolidation of UTF-8 decoding:



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

More information about the core-libs-dev mailing list