tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 32d9054e1eaaffbef95b75c8fe4e09f896c9d571
parent fa28d7b2360041d7e2f77d79b965a6e27a41fb1f
Author: André Bargull <andre.bargull@gmail.com>
Date:   Mon, 24 Nov 2025 18:57:58 +0000

Bug 2002053: Mark default constructors of uint8_clamped and float16 constexpr. r=spidermonkey-reviewers,mgaudet

These constructors can be marked `constexpr`, now that the default language
version is C++20.

Differential Revision: https://phabricator.services.mozilla.com/D273871

Diffstat:
Mjs/src/vm/Float16.h | 9+--------
Mjs/src/vm/Uint8Clamped.h | 9+--------
2 files changed, 2 insertions(+), 16 deletions(-)

diff --git a/js/src/vm/Float16.h b/js/src/vm/Float16.h @@ -205,14 +205,7 @@ class float16 final { uint16_t val; public: - // The default constructor can be 'constexpr' when we switch to C++20. - // - // C++17 requires explicit initialization of all members when using a - // 'constexpr' default constructor. That means `val` needs to be initialized - // through a member initializer. But adding a member initializer makes the - // class no longer trivial, which breaks memcpy/memset optimizations. - - /* constexpr */ float16() = default; + constexpr float16() = default; constexpr float16(const float16&) = default; explicit float16(float x) : val(half::float2half_impl(x)) {} diff --git a/js/src/vm/Uint8Clamped.h b/js/src/vm/Uint8Clamped.h @@ -32,14 +32,7 @@ class uint8_clamped final { } public: - // The default constructor can be 'constexpr' when we switch to C++20. - // - // C++17 requires explicit initialization of all members when using a - // 'constexpr' default constructor. That means `val` needs to be initialized - // through a member initializer. But adding a member initializer makes the - // class no longer trivial, which breaks memcpy/memset optimizations. - - /* constexpr */ uint8_clamped() = default; + constexpr uint8_clamped() = default; constexpr uint8_clamped(const uint8_clamped&) = default; constexpr explicit uint8_clamped(uint8_t x) : val(x) {}