Closed Bug 1687463 Opened 4 months ago Closed 4 months ago

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


(Core :: JavaScript Engine, task, P2)




86 Branch
Tracking Status
firefox86 --- fixed


(Reporter: anba, Assigned: anba)



(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

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
Part 1: Replace mozilla::ArrayLength with ranged for-loops. r=jonco
Part 2: Replace mozilla::ArrayLength with js_strlen. r=jonco
Part 3: Remove no longer needed code for old libstdc++ versions. r=jonco
Part 4: Replace mozilla::ArrayLength with std::size. r=jonco
Part 5: Replace mozilla::ArrayEnd with std::end. r=jonco
Part 6: Remove mozilla::ArrayLength in loop with std::find_if. r=jonco
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.