-
Notifications
You must be signed in to change notification settings - Fork 6.3k
8368172: Make java.time.format.DateTimePrintContext immutable #26913
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
base: master
Are you sure you want to change the base?
Conversation
👋 Welcome back swen! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java
Outdated
Show resolved
Hide resolved
src/java.base/share/classes/java/time/format/DateTimePrintContext.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Chen Liang <liach@openjdk.org>
Webrevs
|
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.
AFAICT this seems like a good change, thanks
src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java
Outdated
Show resolved
Hide resolved
What is the performance data that makes justifies this change? Its not enough to just want to make things constant. |
…Builder.java Co-authored-by: Stephen Colebourne <scolebourne@joda.org>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
The current branch is just a refactoring; there's no performance improvement on MacBook M1 Pro. Further changes are needed to enable the "EliminateAllocations" optimization to work, achieving the goal of eliminating the allocation of DateTimePrintContext and StringBuilder objects in the My plan is to optimize the performance of Therefore, I've broken this process down into multiple PRs, including the current PR #26913, another PR #26911, and the already merged PR #26633. |
This change proposes to make every PrinterParser necessarily handle the optionality that is supported by a few printer parsers. For some, like literals, it makes no sense at all. It adds complexity to the PrinterParser interface. |
This has a much more invasive impact on PrinterParsers than the version with an extra argument on the format method. |
I also agree that # The advantage of the current version is that it clearly defines "optional" as a feature that is handled during build time, rather than during formatting. |
I propose to make j.t.f.DateTimePrintContext immutable.
Currently, DateTimePrintContext has only one mutable field, optional. This can be replaced by adding an optional parameter to the DateTimeFormatter.formatTo method.
Immutable DateTimePrintContext can be optimized by escape analysis, such as immutable object optimization.
Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26913/head:pull/26913
$ git checkout pull/26913
Update a local copy of the PR:
$ git checkout pull/26913
$ git pull https://git.openjdk.org/jdk.git pull/26913/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 26913
View PR using the GUI difftool:
$ git pr show -t 26913
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26913.diff
Using Webrev
Link to Webrev Comment