-
Notifications
You must be signed in to change notification settings - Fork 145
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 #459
Conversation
👋 Welcome back chadrako! A progress list of the required criteria for merging this PR into |
This backport pull request has now been updated with issue from the original commit. |
Webrevs
|
for (int k = 0; k < width - len; k++) | ||
sb.insert(begin, zero); | ||
if (width > len && f.contains(Flags.ZERO_PAD)) { | ||
String zeros = new String(new char[width - len]).replace("\0", "0"); |
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 the original patch, we use the locale-dependent zero
variable here. I don't think we can just use 0
, although I struggle to imagine the case where that would matter. Plus, given we are changing char->char, we can use String.replace(char,char)
instead of String.replace(CharSequence,CharSequence)
.
I think we can hit these two birds with one stone by doing:
char[] zeros = new char[width - len];
Arrays.fill(zeros, zero);
sb.insert(begin, new String(zeros));
It is still awkward because String
constructor copies the array. For extreme use cases, there is a package-private String(char[] array, boolean share)
constructor that might be accessible through SharedSecrets.getJavaLangAccess().newSharedString(...)
(needs a new method). But that might be moot point since AbstractStringBuilder.insert
already does a lot of copies.
if (width > len && f.contains(Flags.ZERO_PAD)) { | ||
char[] zeros = new char[width - len]; | ||
Arrays.fill(zeros, zero); | ||
sb.insert(begin, new String(zeros)); |
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.
Oh wait, we actually have StringBuilder.insert(char[],int)
! That's useful, we don't need to do new String()
then?
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.
More comments.
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.
Looks good, except please change the Formatter.java copyright end date to 2023 to match the original commit.
Should the test |
Yes, I overlooked that. |
@chadrako This change now passes all automated pre-integration checks. 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 55 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. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@shipilev, @phohensee, @gnu-andrew) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
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.
Lgtm, but you need Aleksey to also re-review.
|
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.
Looks good to me.
/approval Backport for fix that improves String.format for large number of zero padding. Backport was not clean since String.repeat and ParameterizedTest are not in JDK8. Users ran into issues with other versions so would like to backport for completeness. Change is simple but medium risk as it touches String.format code |
@chadrako usage: |
/approval 8299677 request Backport for fix that improves String.format for large number of zero padding. Backport was not clean since String.repeat and ParameterizedTest are not in JDK8. Users ran into issues with other versions so would like to backport for completeness. Change is simple but medium risk as it touches String.format code |
@chadrako This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
Commenting to keep PR open. Can a maintainer take a look at this request? |
@chadrako This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
@chadrako This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the |
/open |
@chadrako This pull request is now open |
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.
Sorry for the delay. Final version looks good. I appreciate the work done to largely rewirte the test for the older JTreg in 8u.
/approve yes |
@gnu-andrew |
/integrate |
/sponsor |
Going to push as commit ddce2b5.
Your commit was automatically rebased without conflicts. |
@phohensee @chadrako Pushed as commit ddce2b5. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Backport of JDK-8299677
Backport was not clean. Rewrote test to not include junit
ParameterizedTest
. Rewrote fix sinceString.repeat
is not in JDK8Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk8u-dev.git pull/459/head:pull/459
$ git checkout pull/459
Update a local copy of the PR:
$ git checkout pull/459
$ git pull https://git.openjdk.org/jdk8u-dev.git pull/459/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 459
View PR using the GUI difftool:
$ git pr show -t 459
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk8u-dev/pull/459.diff
Webrev
Link to Webrev Comment