On Sat, 21 Jan 2023 21:01:48 GMT, Sergey Tsypanov <stsypa...@openjdk.org> wrote:
> Currently it's O(n) - we do `n` shifts of bytes within `StringBuilder`. This > can be reduced to O(1) improving the code like: > > DateTimeFormatter dtf = new DateTimeFormatterBuilder() > .appendLiteral("Date:") > .padNext(20, ' ') > .append(DateTimeFormatter.ISO_DATE) > .toFormatter(); > String text = dtf.format(LocalDateTime.now()); This pull request has now been integrated. Changeset: 561ec9c5 Author: Sergey Tsypanov <stsypa...@openjdk.org> Committer: Roger Riggs <rri...@openjdk.org> URL: https://git.openjdk.org/jdk/commit/561ec9c5a06e5baeb0cf72463d14d1d720facb13 Stats: 84 lines in 2 files changed: 83 ins; 0 del; 1 mod 8300818: Reduce complexity of padding with DateTimeFormatter Reviewed-by: redestad, rriggs ------------- PR: https://git.openjdk.org/jdk/pull/12131