Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8311207: Cleanup for Optimization for UUID.toString #14745

Closed
wants to merge 19 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/java.base/share/classes/java/util/HexDigits.java
Original file line number Diff line number Diff line change
@@ -105,18 +105,18 @@ private HexDigits() {
/**
* Return a big-endian packed integer for the 4 ASCII bytes for an input unsigned short value.
*/
static int packDigits16(int b) {
return (DIGITS[(b >> 8) & 0xff] << 16) | DIGITS[b & 0xff];
static int packDigits(int b0, int b1) {
return (DIGITS[b0 & 0xff] << 16) | DIGITS[b1 & 0xff];
}

/**
* Return a big-endian packed long for the 8 ASCII bytes for an input unsigned int value.
*/
static long packDigits32(int b) {
return (((long) DIGITS[(b >> 24) & 0xff]) << 48)
| (((long) DIGITS[(b >> 16) & 0xff]) << 32)
| (DIGITS[(b >> 8) & 0xff] << 16)
| DIGITS[b & 0xff];
static long packDigits(int b0, int b1, int b2, int b3) {
return (((long) DIGITS[b0 & 0xff]) << 48)
| (((long) DIGITS[b1 & 0xff]) << 32)
| (DIGITS[b2 & 0xff] << 16)
| DIGITS[b3 & 0xff];
}

@Override
12 changes: 6 additions & 6 deletions src/java.base/share/classes/java/util/UUID.java
Original file line number Diff line number Diff line change
@@ -473,36 +473,36 @@ public String toString() {
unsafe.putLongUnaligned(
buf,
Unsafe.ARRAY_BYTE_BASE_OFFSET,
HexDigits.packDigits32((int) (msb >> 32)),
HexDigits.packDigits((int) (msb >> 56), (int) (msb >> 48), (int) (msb >> 40), (int) (msb >> 32)),
true);
buf[8] = '-';
unsafe.putIntUnaligned(
buf,
Unsafe.ARRAY_BYTE_BASE_OFFSET + 9,
HexDigits.packDigits16(((int) msb) >> 16),
HexDigits.packDigits(((int) msb) >> 24, ((int) msb) >> 16),
true);
buf[13] = '-';
unsafe.putIntUnaligned(
buf,
Unsafe.ARRAY_BYTE_BASE_OFFSET + 14,
HexDigits.packDigits16((int) msb),
HexDigits.packDigits(((int) msb) >> 8, (int) msb),
true);
buf[18] = '-';
unsafe.putIntUnaligned(
buf,
Unsafe.ARRAY_BYTE_BASE_OFFSET + 19,
HexDigits.packDigits16((int) (lsb >> 48)),
HexDigits.packDigits((int) (lsb >> 56), (int) (lsb >> 48)),
true);
buf[23] = '-';
unsafe.putLongUnaligned(
buf,
Unsafe.ARRAY_BYTE_BASE_OFFSET + 24,
HexDigits.packDigits32((int) (lsb >> 16)),
HexDigits.packDigits(((int) (lsb >> 40)), (int) (lsb >> 32), ((int) lsb) >> 24, ((int) lsb) >> 16),
true);
unsafe.putIntUnaligned(
buf,
Unsafe.ARRAY_BYTE_BASE_OFFSET + 32,
HexDigits.packDigits16((int) lsb),
HexDigits.packDigits(((int) lsb) >> 8, (int) lsb),
true);

try {