-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8299677: Formatter.format might take a long time to format an integer or floating-point #11939
Conversation
… or floating-point
👋 Welcome back rgiulietti! A progress list of the required criteria for merging this PR into |
@rgiulietti The following labels will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
I assume this issue has been there for a long time, just not noticed because it would be unusual to specify a width of this magnitude. The switch to using repeat + one insert looks good. Are we okay for tests in this area? |
@AlanBateman This is not a functional bug, only an enhancement to overcome the long times for large, unrealistic widths. |
Just as a note, I've been thinking about adding a |
My question wasn't phrased very well, I was really just asking if we have good test coverage for width in the format specifier so that it would catch any regressions from changes to this code. |
Since specific tests for padding seem lacking, I'll add some as part of this PR. |
… or floating-point
Added straightforward tests for padding. |
… or floating-point
… or floating-point
sb.insert(begin, zero); | ||
} | ||
if (width > sb.length() && Flags.contains(f, Flags.ZERO_PAD)) { | ||
String zeros = Character.toString(zero).repeat(width - sb.length()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Character.toString(zero)
could be replaced directly with String.valueOf(zero)
saving one more method call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the bug going to be backported to JDK8? Due to the use of 'repeat' this seems to not be possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for expanding the tests for this.
|
||
/* | ||
* @test | ||
* @run junit Padding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rgiulietti This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 42 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this looks OK.
Please add either a general comment describing what we are trying to test or a comment for each test method. As we add new tests, adding comments for additional clarity will benefit future maintainers
@Nested | ||
class BlankPaddingInt { | ||
|
||
@Test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any thought given to using @MethodSource:
in order to specify a DataProvider? The benefit would be you could catch each failure vs having to address or comment out the assertEquals that is failing
… or floating-point
All concerns were addressed, I hope. |
/integrate |
Going to push as commit 33412c1.
Your commit was automatically rebased without conflicts. |
@rgiulietti Pushed as commit 33412c1. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in which JDK versions will the bug-fix back ported? As it is, it is impossible to be back ported to JDK8
sb.insert(begin, zero); | ||
} | ||
if (width > sb.length() && Flags.contains(f, Flags.ZERO_PAD)) { | ||
String zeros = Character.toString(zero).repeat(width - sb.length()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the bug going to be backported to JDK8? Due to the use of 'repeat' this seems to not be possible.
@balcanuc Backporting is done in other, separate projects. Whether changes in mainline are backported, and how, is publicly discussed in the respective mailing lists. In particular, for JDK 8 Updates you might want to have a look at If you feel this change is relevant to JDK 8, you are welcome to discuss a solution that does not rely on |
This change transforms a O(n^2) path to O(n) when prepending zero padding to decimal outputs, where n is the length of the padding.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/11939/head:pull/11939
$ git checkout pull/11939
Update a local copy of the PR:
$ git checkout pull/11939
$ git pull https://git.openjdk.org/jdk pull/11939/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 11939
View PR using the GUI difftool:
$ git pr show -t 11939
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/11939.diff