Closed Bug 1737814 Opened 3 years ago Closed 3 years ago

Refactor ListFormat::FormatToParts

Categories

(Core :: Internationalization, enhancement, P4)

enhancement

Tracking

()

RESOLVED FIXED
96 Branch
Tracking Status
firefox96 --- fixed

People

(Reporter: allstars.chh, Assigned: allstars.chh)

References

Details

Attachments

(3 files)

There are some improvements learned from DateTimeFormat implementation that could help ListFormat::FormatToParts, for example:

  1. No need to use a callback.
    We could pass a Buffer, and that buffer holds the string result, so the strings got for ICU could still remain valid after the FormatToParts call.
    Also, when I implemented DateIntervalFormat, I found std::function will do heap allocation when the lambda size is too large.

  2. Simplify the data structures in ListFormat::Part.
    We could just store an index to the string buffer, instead of a Mozilla::Span.

Marking this as P4 since it's on the non-critical path for unification, that way it won't show up in the graph for the KRs. Feel free to continue the clean-up on it though.

Priority: P1 → P4

This AutoFormatResult class could be shared later by ListFormat.

The caller now will provide a buffer, which owns the memory pointed by the span.

Pushed by allstars.chh@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/9459574a7ee2
Part 1: Add a AutoFormatResult class. r=platform-i18n-reviewers,anba,gregtatum
https://hg.mozilla.org/integration/autoland/rev/a3a54dca1620
Part 2: ListFormat.FormatToParts doesn't take a callback. r=platform-i18n-reviewers,anba,gregtatum
https://hg.mozilla.org/integration/autoland/rev/0480317c00e5
Part 3: Simplify parts data structure. r=platform-i18n-reviewers,anba,gregtatum
Regressions: 1742592
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: