mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8299677: Formatter.format might take a long time to format an integer or floating-point
Reviewed-by: alanb, stsypanov, darcy
This commit is contained in:
parent
7a85d95e82
commit
33412c102c
2 changed files with 317 additions and 5 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -4596,10 +4596,9 @@ public final class Formatter implements Closeable, Flushable {
|
|||
}
|
||||
|
||||
// apply zero padding
|
||||
if (width != -1 && Flags.contains(f, Flags.ZERO_PAD)) {
|
||||
for (int k = sb.length(); k < width; k++) {
|
||||
sb.insert(begin, zero);
|
||||
}
|
||||
if (width > sb.length() && Flags.contains(f, Flags.ZERO_PAD)) {
|
||||
String zeros = String.valueOf(zero).repeat(width - sb.length());
|
||||
sb.insert(begin, zeros);
|
||||
}
|
||||
|
||||
return sb;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue