-
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
ZeroCopy aliases #1777
ZeroCopy aliases #1777
Conversation
@Manishearth could you please take a look at the |
@robertbastian I have a fix, along with code making the rest of your stuff compile; mind if I push to the same branch? |
Commits are at https://github.com/Manishearth/icu4x/tree/pr-1777, either way. I plan to extract some of it to a separate PR, for one the trait implementation situation is annoying and will likely get worse |
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.
Good job: This is a challenging PR to write that leverages a large portion of the zerovec machinery!
.iter() | ||
.map(zerofrom::ZeroFrom::zero_from) | ||
{ | ||
if let Ok(from) = raw_from.parse::<LanguageIdentifier>() { |
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.
Note: I think this is still parsing each time for all canonicalize operations
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.
^ Please fix if this causes us to allocate memory for every operation. If there is no memory being allocated, this is a nice-to-fix but not must-fix
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.
Yes it is, but this is the fallback field which we're trying to keep empty. If you have a way to check uts35_rule_matches
on a string I'm all ears, but I don't see it without parsing.
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.
To do this without allocation we could make Variants
a Cow<'data, str>
. The only functionality it has is to iterate through the variants, which would be very cheap with something like self.0.split('-').map(Variant::from_raw_unchecked)
. The downside would be that this adds a lifetime to LanguageIdentifier
and Locale
.
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.
OK, if this is for fallback data, and fallback data is currently empty, I have no concerns.
Modifying the data model of LanguageIdentifier or Locale is understood to be off the table with much discussion in #831.
Closes #1034