unicode-org / icu4x

Solving i18n for client-side and resource-constrained environments.
https://icu4x.unicode.org
Other
1.38k stars 178 forks source link

Reduce stack size of DecimalSymbolsV1 #5804

Closed Manishearth closed 1 week ago

Manishearth commented 1 week ago

Fixes https://github.com/unicode-org/icu4x/issues/4437

This doesn't work yet: there's no easy way to get Bake impls for custom VarULE types since from_byte_slice_unchecked can't be called in const contexts (since you can't do trait stuff in non-const contexts: in theory this function is very const-capable)

I chose to use make_varule but VarTupleNULE would work as well (and plus we can give it the relevant Bake impl if we want). I wrote this PR to encapsulate things so that swapping the internals is easier

I think I'll make this work by implementing ZeroCow: https://github.com/unicode-org/icu4x/issues/5561

Manishearth commented 1 week ago

Updated to use https://github.com/unicode-org/icu4x/pull/5809 and https://github.com/unicode-org/icu4x/pull/5808

Manishearth commented 1 week ago

ugh. @sffc the md test for tweaking data providers uses new_default. I don't want to use the internal testing replacement, and using Baked data to get the default would be messy.

What do you recommend we do here?

I think it's possible that the new DecimalSymbols is no longer ideal for use in a tutorial, perhaps we should pick something else? List format?

sffc commented 1 week ago

I think it's possible that the new DecimalSymbols is no longer ideal for use in a tutorial, perhaps we should pick something else? List format?

Um... weekday names?

Manishearth commented 1 week ago

(Discussed with Shane in person: I just loaded data from Baked, it's not too noisy and most users of this will need to do something like that anyway so it's not out of place in the tutorial, which was my initial worry)

sffc commented 1 week ago
---- datagen::test_markers_for_bin stdout ----
thread 'datagen::test_markers_for_bin' panicked at components/icu/src/datagen.rs:96:5:
assertion `left == right` failed
  left: [datetime/names/dayperiods@1, datetime/names/gregory/months@1, datetime/names/gregory/years@1, datetime/names/weekdays@1, datetime/patterns/glue@1, datetime/patterns/gregory/skeleton@1, datetime/patterns/time_skeleton@1, datetime/week_data@2]
 right: [datetime/names/dayperiods@1, datetime/names/gregory/months@1, datetime/names/gregory/years@1, datetime/names/weekdays@1, datetime/patterns/glue@1, datetime/patterns/gregory/skeleton@1, datetime/patterns/time_skeleton@1, datetime/week_data@2, decimal/symbols@2]