Modernise intl::Locale
Categories
(Core :: Internationalization, task)
Tracking
()
Tracking | Status | |
---|---|---|
firefox95 | --- | fixed |
People
(Reporter: anba, Assigned: anba)
Details
Attachments
(9 files)
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review |
The initial port of mozilla::intl::Locale
kept some SpiderMonkey specific designs, which aren't necessarily appropriate for general uses.
For example:
Locale::unicodeExtension()
returnsconst char*
, wherenullptr
indicates an absent Unicode extension. A better design for general purposeLocale
is probably returningMaybe<Span<const char>>
.Locale::addLikelySubtags()
returnsbool
wherefalse
indicates the failure case instead of usingICUResult
.- The original code (bug 1570370) was created before bug 1583953, so I couldn't use
operator==
andoperator<
frommozilla::Span
and instead usedstd::char_traits
extensively.
Assignee | ||
Comment 1•3 years ago
|
||
The original code was created before bug 1583953 and at that point of time, the
Span
operators where still costly to call due to release-assertions overhead.
With the release assertions removed, the Span
operators are now just as efficient
as manually calling std::char_traits
. (Both will compile down to plain memcmp
calls.) But compared to using std::char_traits
, the Span
operators are more
ergonomic to use and result in less written code.
Depends on D129036
Assignee | ||
Comment 2•3 years ago
|
||
Return ICUResult
from Locale::{add,remove}LikelySubtags()
instead of using bool
.
Depends on D129037
Assignee | ||
Comment 3•3 years ago
|
||
Return ICUResult
from Locale::setUnicodeExtension()
instead of using bool
.
Depends on D129038
Assignee | ||
Comment 4•3 years ago
|
||
This avoids unnecessary null-termination for the callers.
Depends on D129039
Assignee | ||
Comment 5•3 years ago
|
||
Depends on D129040
Assignee | ||
Comment 6•3 years ago
|
||
Use Maybe
and return Span
instead of raw const char*
.
Depends on D129041
Assignee | ||
Comment 7•3 years ago
|
||
Use Maybe
and return Span
instead of raw const char*
.
Depends on D129042
Assignee | ||
Comment 8•3 years ago
|
||
Use direct member access in preparation for the next part.
Depends on D129043
Assignee | ||
Comment 9•3 years ago
|
||
Expose both members only as an iterable structure to hide implementation details
like the UniqueChars
storage.
Depends on D129044
Comment 10•3 years ago
|
||
Comment 11•3 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/c6d8f836668e
https://hg.mozilla.org/mozilla-central/rev/198e41713023
https://hg.mozilla.org/mozilla-central/rev/34e727062e6c
https://hg.mozilla.org/mozilla-central/rev/aa05e4759185
https://hg.mozilla.org/mozilla-central/rev/1fea7abd8773
https://hg.mozilla.org/mozilla-central/rev/29911ad4824e
https://hg.mozilla.org/mozilla-central/rev/043a907d0d3f
https://hg.mozilla.org/mozilla-central/rev/6dd568c25660
https://hg.mozilla.org/mozilla-central/rev/e64bbe494da4
Description
•