Closed Bug 1748395 Opened 1 year ago Closed 1 year ago

Use `if constexpr` for expressions that can be determined at compile time

Categories

(Core :: Layout: Text and Fonts, task)

task

Tracking

()

RESOLVED FIXED
97 Branch
Tracking Status
firefox97 --- fixed

People

(Reporter: TYLin, Assigned: TYLin)

Details

Attachments

(1 file)

In gfxFont.cpp and gfxTextRun.cpp, some template methods have logic that is intended only for 8-bit or 16-bit text such as [1].

if (sizeof(T) == sizeof(char16_t)) {
    ....
}

This kind of if expression can be determined at the compile time, so it's better to use if constexpr.

[1] https://searchfox.org/mozilla-central/rev/855814f769ac55bbb6a00e2170a6a876ab4cff3a/gfx/thebes/gfxFont.cpp#2971-2973

The compiler might already be smart enough to not generate code in an
if-statement that guarantees to be false at compile time. However it's no harm
to make it explicit by using if constexpr.

Pushed by aethanyc@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/01217db0e1fc
Use `if constexpr` for expressions that can be determined at compile time. r=emilio

Backed out changeset 01217db0e1fc (Bug 1748395) for causing build bustages on gfxFont.cpp.
Backout link
Push with failures
Failure Log

Flags: needinfo?(aethanyc)
Pushed by aethanyc@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/7ee415205518
Use `if constexpr` for expressions that can be determined at compile time. r=emilio
Flags: needinfo?(aethanyc)
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 97 Branch
You need to log in before you can comment on or make changes to this bug.