On Thu, 25 Jul 2024 21:52:03 GMT, Shaojin Wen <d...@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.
>
> Shaojin Wen has updated the pull request incrementally with two additional 
> commits since the last revision:
> 
>  - add comments
>  - reduce change

src/java.base/share/classes/java/time/LocalDate.java line 2157:

> 2155: 
> 2156:     /**
> 2157:      *  Outputs this date into {@code StringBuilder}, such as {@code 
> 2007-12-03}.

You shouldn't copy the docs for `toString` as that is not we should be careful 
about using this `formatTo`. You should write something helpful like:

/**
 * Prints the toString result to the given buf, avoiding extra string 
allocations.
 * Requires extra capacity of 10 to avoid StringBuilder reallocation.
 */

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

> 1638: 
> 1639:     /**
> 1640:      * Outputs this time into {@code StringBuilder}, such as {@code 
> 10:15}.

Same here:

/**
 * Prints the toString result to the given buf, avoiding extra string 
allocations.
 * Requires extra capacity of 18 to avoid StringBuilder reallocation.
 */

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20321#discussion_r1692207893
PR Review Comment: https://git.openjdk.org/jdk/pull/20321#discussion_r1692209966

Reply via email to