Replace mozilla::{ArrayLength,ArrayEnd} with STL functions
Categories
(Core :: JavaScript Engine, task, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox86 | --- | fixed |
People
(Reporter: anba, Assigned: anba)
Details
Attachments
(7 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 |
mozilla::ArrayLength()
on string constants can be replaced withstd::char_traits::length()
.mozilla::ArrayLength()
in simple for-loops can be replaced with ranged for-loops.- In all other cases,
mozilla::ArrayLength()
can be replaced withstd::size()
. mozilla::ArrayEnd()
can be replaced withstd::end()
.
Assignee | ||
Comment 2•4 years ago
|
||
Calling mozilla::ArrayLength()
on strings requires to subtract one to account
for the trailing null-character. This isn't necessary when
std::char_traits<T>::length()
is used.
constexpr
evaluation of std::char_traits<T>::length()
requires its input to
be a constexpr
string. A handful of strings were therefore changed from const
to constexpr
.
Depends on D102295
Assignee | ||
Comment 3•4 years ago
|
||
We're already using the constexpr
calls to std::char_traits<T>::length()
in
other code, so this fallback code doesn't seem necessary anymore.
(The code in "NumberFormat.cpp" predates the GCC version bump in bug 1536848.)
Depends on D102296
Assignee | ||
Comment 4•4 years ago
|
||
Replace all other uses of mozilla::ArrayLength()
with the stl function
std::size()
.
Depends on D102297
Assignee | ||
Comment 5•4 years ago
|
||
Replace mozilla::ArrayEnd()
with the stl function std::end()
.
Depends on D102299
Assignee | ||
Comment 6•4 years ago
|
||
Instead of just replace mozilla::ArrayLength
with std::size
, replace the
whole loop statement with a call to std::find_if
.
Depends on D102300
Assignee | ||
Comment 7•4 years ago
|
||
Only include "mozilla/ArrayUtils.h" when actually needed.
Depends on D102304
Updated•4 years ago
|
Updated•4 years ago
|
Pushed by dluca@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/998d5f1f185a Part 1: Replace mozilla::ArrayLength with ranged for-loops. r=jonco https://hg.mozilla.org/integration/autoland/rev/decc251d4c7b Part 2: Replace mozilla::ArrayLength with js_strlen. r=jonco https://hg.mozilla.org/integration/autoland/rev/8cfea455f0e0 Part 3: Remove no longer needed code for old libstdc++ versions. r=jonco https://hg.mozilla.org/integration/autoland/rev/91f481d8546c Part 4: Replace mozilla::ArrayLength with std::size. r=jonco https://hg.mozilla.org/integration/autoland/rev/ad1e8f06cfee Part 5: Replace mozilla::ArrayEnd with std::end. r=jonco https://hg.mozilla.org/integration/autoland/rev/9be1510d9e83 Part 6: Remove mozilla::ArrayLength in loop with std::find_if. r=jonco https://hg.mozilla.org/integration/autoland/rev/0933f32abb68 Part 7: Clean-up includes to mozilla/ArrayUtils.h. r=jonco
Comment 9•4 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/998d5f1f185a
https://hg.mozilla.org/mozilla-central/rev/decc251d4c7b
https://hg.mozilla.org/mozilla-central/rev/8cfea455f0e0
https://hg.mozilla.org/mozilla-central/rev/91f481d8546c
https://hg.mozilla.org/mozilla-central/rev/ad1e8f06cfee
https://hg.mozilla.org/mozilla-central/rev/9be1510d9e83
https://hg.mozilla.org/mozilla-central/rev/0933f32abb68
Description
•