Open
Bug 1729643
Opened 3 years ago
Updated 10 months ago
Use `if constexpr (...)` for template with enum parameter
Categories
(Core :: JavaScript Engine, enhancement, P5)
Core
JavaScript Engine
Tracking
()
NEW
People
(Reporter: arai, Unassigned)
References
(Blocks 1 open bug)
Details
XDR functions uses XDRMode
template parameter, and uses it as condition for encode/decode branches.
example code from https://phabricator.services.mozilla.com/D121274
template <XDRMode mode>
/* static */
XDRResult StencilXDR::codeSharedData(XDRState<mode>* xdr,
RefPtr<SharedImmutableScriptData>& sisd) {
...
if constexpr (mode == XDR_ENCODE) {
...
} else {
...
const auto& options = static_cast<XDRStencilDecoder*>(xdr)->options();
if (options.usePinnedBytecode) {
using if constexpr
for the branch allows using static_cast
there,
(XDRStencilDecoder
is subclass of XDRState<XDR_DECODE>
),
and similar simplification can be done for some other places.
You need to log in
before you can comment on or make changes to this bug.
Description
•