RFR: JDK-8310502 : Optimization for j.l.Long.fastUUID() [v21]
ExE Boss
duke at openjdk.org
Sat Jun 24 23:39:05 UTC 2023
On Fri, 23 Jun 2023 23:25:25 GMT, 温绍锦 <duke at openjdk.org> wrote:
>> src/java.base/share/classes/java/lang/Long.java line 493:
>>
>>> 491: | H256[((int) lsb) & 0xff]);
>>> 492:
>>> 493: return new String(buf, LATIN1);
>>
>> Note that this isn’t correct when `COMPACT_STRINGS` is `false`, as then `buf` is always interpreted as having a `coder` of `UTF16`.
>
> where COMPACT_STRINGS is false, jdk.internal.access.JavaLangAccess#fastUUID using fastUUIDUTF16
>
>
> public String fastUUID(long lsb, long msb) {
> return String.COMPACT_STRINGS ? Long.fastUUID(lsb, msb) : Long.fastUUIDUTF16(lsb, msb);
> }
There should probably be a check or something at the top of this method that `COMPACT_STRINGS` is `true` then, e.g.:
if (!COMPACT_STRINGS) {
throw new InternalError("...");
}
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/14578#discussion_r1240970991
More information about the core-libs-dev
mailing list