-
Notifications
You must be signed in to change notification settings - Fork 180
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
Make DateTimeFormat Patterns use ZeroVec #519
Comments
Since 0.3 is already 3 weeks late, we suggest moving all incomplete issues to 0.4. |
Here is one way we could express Pattern as a ZeroVec: (Oops: In the Jamboard, I expressed my code points in big-endian instead of little-endian.) In code, this would be something like #[derive(Copy)]
struct EncodedPatternItem([u8; 3]);
struct Pattern<'data> {
items: ZeroVec<'data, EncodedPatternItem>,
};
impl EncodedPatternItem {
#[inline]
fn get_discriminant(&self) { /* extract the first bit */ }
#[inline]
fn get_code_point(&self) { /* extract the code point bits */ }
#[inline]
fn get_key(&self) { /* extract the key bits */ }
#[inline]
fn get_value(&self) { /* extract the value bits */ }
} Or, perhaps, // same definition of EncodedPatternItem
#[derive(Copy)]
enum PatternItem<K, V>
where
K: Copy + /* encodable to a single byte */,
V: Copy + /* encodable to a single byte */,
{
Field(K, V),
Char(char),
}
impl<K, V> AsULE for PatternItem<K, V> {
type ULE = EncodedPatternItem;
// ...
}
struct Pattern<'data, K, V> {
items: ZeroVec<'data, PatternItem<K, V>>,
}; In other words, in This is generalizable to other types of patterns, such as list patterns and currency/unit affix patterns. Advantages:
Disadvantages:
Considerations (neither advantages nor disadvantages):
CC @Manishearth |
The final piece of the puzzle is the cleanup in skeleton code. In particular I believe we should:
The latter two I'd prefer not to do now, so I'm going to spin off separate issues for it, but the first three I think are worth doing now. |
DONE !!! :D |
While wanting to test my PR for #277 I started looking at the DTF pattern/parser.
It currently is pretty inefficient as it allocates new Strings for each literal and grows them and then allocates a vector of items just to populate a buffer.
I'd like to remodel it in the following steps:
PatternItem::Literal
to be aCow
&str
andCow
fromCow
.The text was updated successfully, but these errors were encountered: