On Sun, 28 Jul 2024 15:52:03 GMT, Shaojin Wen <d...@openjdk.org> wrote:
>> By removing the redundant code logic in >> DateTimeFormatterBuilder$InstantPrinterParser#formatTo, the codeSize can be >> reduced and the performance can be improved. > > Shaojin Wen has updated the pull request incrementally with one additional > commit since the last revision: > > 1. fix handle fraction == -1 > 2. Split two methods to make codeSize less than 325 @jodastephen thank you for your patience in answering my questions. Now I've used a new way to implement it, splitting it into two sub-methods without changing the original logic, which also makes codeSize < 325, and the performance is also faster than before. Here are the performance numbers running on a MacBook M1 Pro: - # master 5ff7c57f9ff5428ef3d2aedd7e860bb1e8ff29ea -Benchmark Mode Cnt Score Error Units -ToStringBench.instantToString thrpt 15 4.558 ? 0.561 ops/ms + # current 757984258257fd82c389f3ee7bd9be927375e2e0 +Benchmark Mode Cnt Score Error Units +ToStringBench.instantToString thrpt 15 5.564 ? 0.465 ops/ms +22.07% I also added relevant tests to prevent errors from being discovered in future related changes. I hope to reuse LocalDateTime.toString for the most common paths, so that we can also use LocalDateTime.formatTo method, which can reduce object allocation. I plan to continue to optimize the formatTo method of LocalTime and LocalDate, so that InstantPrinterParser.format can also benefit from it. ------------- PR Comment: https://git.openjdk.org/jdk/pull/20353#issuecomment-2254582635