-
Notifications
You must be signed in to change notification settings - Fork 177
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
Optimize YearNames storage #5602
Comments
I really like this design. It seems consistent with what we did with the LeapLinear design: optimize the data structure based on what calendars actually need. Using era codes instead of numeric indices for Japanese seems like the right call. |
While we're here, we should take a look at the encoding of
where you binary-search for the key before the |
Hmm, not entirely opposed, though that is super hacky. |
It's not super hacky if you think of it as a stringly typed VarVarULE with ":" as the field separator. |
Might need to choose a field separator that is always greater than or less than BCP-47 so that sorting works correctly. |
Currently YearNames are stored as "eras" (a zeromap) or "cyclic" (a varzerovec).
Most calendars have either a single era, or a small fixed set of eras (gregory, coptic, ethiopic). Only Japanese has many. The map is wasteful in these cases, we have thousands of entries for YearNames that repeat the era names over and over again.
What if we optimized most calendars to have a VarZeroVec of eras?
and then formatting eras can be
enum FormattingEra { Index(u8), Code(EraCode) }
. We can assign index 0 to the "extended year era" for consistency.We'd need to be careful in the ethiopic shared-era situation to assign indices in such a way that both calendars share indices.
In fact we could even go one further and use a VarZeroVec for Japanese, but this is fraught in the face of maintaining the index mapping.
cc @zbraniecki @sffc
The text was updated successfully, but these errors were encountered: