Closed Bug 1687463 Opened 4 months ago Closed 4 months ago

Replace mozilla::{ArrayLength,ArrayEnd} with STL functions

Categories

(Core :: JavaScript Engine, task, P2)

task

Tracking

()

RESOLVED FIXED
86 Branch
Tracking Status
firefox86 --- fixed

People

(Reporter: anba, Assigned: anba)

Details

Attachments

(7 files)

  • mozilla::ArrayLength() on string constants can be replaced with std::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 with std::size().
  • mozilla::ArrayEnd() can be replaced with std::end().

Replaces calls to mozilla::ArrayLength with ranged for-loops.

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

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

Replace all other uses of mozilla::ArrayLength() with the stl function
std::size().

Depends on D102297

Replace mozilla::ArrayEnd() with the stl function std::end().

Depends on D102299

Instead of just replace mozilla::ArrayLength with std::size, replace the
whole loop statement with a call to std::find_if.

Depends on D102300

Only include "mozilla/ArrayUtils.h" when actually needed.

Depends on D102304

Attachment #9197927 - Attachment description: Bug 1687463 - Part 2: Replace mozilla::ArrayLength with std::char_traits::length. r=jonco! → Bug 1687463 - Part 2: Replace mozilla::ArrayLength with js_strlen. r=jonco!
Severity: -- → N/A
Priority: -- → P2
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
You need to log in before you can comment on or make changes to this bug.