icu4x icon indicating copy to clipboard operation
icu4x copied to clipboard

Improve Extraction of Power and SI Prefix from CLDR Units String & implement `strip_prefix` for `zerotrie`

Open younies opened this issue 2 years ago • 2 comments

This issue pertains to the get_power and get_si_prefix functions in the MeasureUnit struct in the experimental/unitsconversion/src/measureunit.rs file. These functions are responsible for extracting the power and SI prefix from a CLDR units string, respectively.

Right now, we are using just a bunch of if and else statements. Which is not the most efficient way.

Option 1:

  • Use zerotrie and store it. Because it will be used while extracting the measurementunit from cldr-id

Aslo, implement strip_prefix in zerotrie

younies avatar Nov 28 '23 13:11 younies

@Manishearth : lets use the if-else for now, until the performance is a problem. @sffc: yes, but we need to wait until the implementation of strip_prefix @robertbastian : I am not convinced that we need the zerotrie until we compare the performance.

Decision: use if-else until and test the usage of zerotrie performance after the implementation of strip_prefix in zerotrie.

LGTM: @younies , @sffc , @robertbastian , @Manishearth

younies avatar Nov 28 '23 16:11 younies

ZeroTrie issue: https://github.com/unicode-org/icu4x/issues/4249

sffc avatar Nov 28 '23 17:11 sffc