-
Notifications
You must be signed in to change notification settings - Fork 182
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
Create TypedNeoDateTimeFormatter and DateTimePattern types #4415
Conversation
e9d20ba
to
52a0ab1
Compare
Background: the current DateTimeFormatter is over 6000 bytes. I've demonstrated in this PR that NeoDateTimeFormatter is around 700 bytes, which is a huge improvement, but we want to see if we can get it even smaller. |
…ment for NeoTimeFormatter
Review tips: It should be easier to review this all at once. Commit-by-commit may result in your reviewing code that I subsequently refactored or deleted. Most of this PR is plumbing. I tried to pull off the interesting parts as I was writing it. There are two more PRs, #4496 and #4497, that are currently open with two small but slightly more interesting bits of code. This PR adds the following public types:
The code in I introduced a new "external loader" design pattern in This implements part of the fix for #4340, but I didn't fix the whole thing in an effort to not scope creep this PR. |
🎉 All dependencies have been resolved ! |
#[allow(clippy::too_many_arguments)] | ||
pub(crate) fn load_for_pattern<YearMarker, MonthMarker>( | ||
&mut self, | ||
year_provider: Option<&(impl DataProvider<YearMarker> + ?Sized)>, |
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.
praise: good on keeping these traits only in the bounds of a single method rather than having them spread everywhere (and causing monomorphized code size issues)
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.
Hmm, with AnyCalendar <YearMarker, MonthMarker>
are not known until runtime and I don't really want to include more than 1 copy of this function (i.e. through an enum switch). Maybe we can move those over to the external loader architecture so that the enum switch is isolated to the load function. Let's figure that out when I implement the AnyCalendar version of neo formatter.
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.
Yep.
/// Trait for loading a FixedDecimalFormatter. | ||
/// | ||
/// Implemented on the provider-specific loader types in this module. | ||
pub(crate) trait FixedDecimalFormatterLoader { |
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.
observation: must stay private, we may need to be able to load RBNF in the long run
in the medium term we will probably hardcode a FixedDecimalFormatter | CustomFormat
where the CustomFormat is a simple enum with code attached.
} | ||
|
||
impl DateTimePattern { | ||
/// Creates a [`DateTimePattern`] from a pattern string. |
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.
nit (nb, followup): roughly document thr format or link to UTS 35.
Part of #3347
Depends on #4496
Depends on #4497