RFR: 8315999: Improve Date toString performance [v9]

ExE Boss duke at openjdk.org
Tue Sep 12 18:01:50 UTC 2023


On Tue, 12 Sep 2023 17:23:00 GMT, 温绍锦 <duke at openjdk.org> wrote:

>> improve date toString performance, includes:
>> 
>> java.util.Date.toString
>> java.util.Date.toGMTString
>> java.time.Instant.toString
>> java.time.LocalDate.toString
>> java.time.LocalDateTime.toString
>> java.time.LocalTime.toString
>
> 温绍锦 has updated the pull request incrementally with one additional commit since the last revision:
> 
>   merge from master

`LocalTime::getNanoChars(byte[], int, int)` can use `DecimalDigits::digitTriple(int)` instead of a local copy of `DecimalDigits.DIGITS_K`:

src/java.base/share/classes/java/time/LocalTime.java line 141:

> 139:     @Stable
> 140:     static final int[] DIGITS_K = new int[1000];
> 141: 

Suggestion:

src/java.base/share/classes/java/time/LocalTime.java line 179:

> 177:             int c3 = i % 10 + '0';
> 178:             DIGITS_K[i] = c0 + (c1 << 8) + (c2 << 16) + (c3 << 24);
> 179:         }

Suggestion:

src/java.base/share/classes/java/time/LocalTime.java line 1710:

> 1708:                 buf,
> 1709:                 off,
> 1710:                 DIGITS_K[div2] & 0xffffff00 | '.'

Suggestion:

                DecimalDigits.digitTriple(div2) & 0xffffff00 | '.'

src/java.base/share/classes/java/time/LocalTime.java line 1722:

> 1720:             }
> 1721: 
> 1722:             v = DIGITS_K[rem2];

Suggestion:

            v = DecimalDigits.digitTriple(rem2);

src/java.base/share/classes/java/time/LocalTime.java line 1724:

> 1722:             v = DIGITS_K[rem2];
> 1723:         } else {
> 1724:             v = DIGITS_K[div - div2 * 1000];

Suggestion:

            v = DecimalDigits.digitTriple(div - div2 * 1000);

src/java.base/share/classes/java/time/LocalTime.java line 1740:

> 1738:                     buf,
> 1739:                     off,
> 1740:                     DIGITS_K[rem1] & 0xffffff00 | (v >> 24)

Suggestion:

                    DecimalDigits.digitTriple(rem1) & 0xffffff00 | (v >> 24)

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

PR Review: https://git.openjdk.org/jdk/pull/15658#pullrequestreview-1622831447
PR Review Comment: https://git.openjdk.org/jdk/pull/15658#discussion_r1323381033
PR Review Comment: https://git.openjdk.org/jdk/pull/15658#discussion_r1323381182
PR Review Comment: https://git.openjdk.org/jdk/pull/15658#discussion_r1323379816
PR Review Comment: https://git.openjdk.org/jdk/pull/15658#discussion_r1323380364
PR Review Comment: https://git.openjdk.org/jdk/pull/15658#discussion_r1323380525
PR Review Comment: https://git.openjdk.org/jdk/pull/15658#discussion_r1323380651



More information about the security-dev mailing list