ITADN

Consider optimizing range patterns

#8060OpenManishearth 创建于 2026-06-10
C-datetime
M
Manishearthcommented
Our current design for range patterns is to store them in PatternsByGreatestDifference, as a pattern. However, most range patterns have a fair amount of duplication: A range pattern will typically look something like `A - A B" where A and B are pattern strings like `y/M/d`. We could recognize this structure and store them in an efficient way so the duplication doesn't actually happen. I'm a little skeptical though: patterns are efficiently packed in a VarULE representation, and these strings are small. Adding more structure to this type will probably make it bigger in a way that doesn't work out. We might be able to make it work by using the pattern metadata and basically hijacking PatternULE to give it more interpretation in the case of range patterns (e.g. "if you see an X field, that just means you repeat the last pattern string"). > I can see two axes: > > * all patterns (seem to) share the same glue (" - ") > * each range pattern often, but not always, repeats the non-range pattern _Originally posted by @robertbastian in https://github.com/unicode-org/icu4x/pull/8034#discussion_r3387075771_
2 条评论