RFR: 8337168: Optimize LocalDateTime.toString

Naoto Sato naoto at openjdk.org
Thu Jul 25 20:42:31 UTC 2024


On Thu, 25 Jul 2024 05:06:17 GMT, Shaojin Wen <duke at openjdk.org> wrote:

> The current LocalDateTime.toString implementation concatenates the toString results of date and time, which can be passed to StringBuilder to reduce additional object allocation and improve performance.

LGTM

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

> 1643:         int nanoValue = nano;
> 1644:         buf.append(hourValue < 10 ? "0" : "").append(hourValue)
> 1645:                 .append(minuteValue < 10 ? ":0" : ":").append(minuteValue);

Nit: unnecessary modification

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

Marked as reviewed by naoto (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/20321#pullrequestreview-2200429700
PR Review Comment: https://git.openjdk.org/jdk/pull/20321#discussion_r1692090342


More information about the core-libs-dev mailing list