diff options
author | Lenny Maiorani <lenny@colorado.edu> | 2021-05-19 09:32:07 -0600 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-05-21 10:07:06 +0100 |
commit | 800ea8ea969835297dc7e7da345a45b9dc5e751a (patch) | |
tree | 5918276b3f75e73d7f4559f97587a23f652612a5 /Userland/Libraries/LibGfx/Painter.cpp | |
parent | 17ff895e1cbc685b99b22856aed16852b564c1f4 (diff) | |
download | serenity-800ea8ea969835297dc7e7da345a45b9dc5e751a.zip |
Userland: static vs non-static constexpr variables
Problem:
- `static` variables consume memory and sometimes are less
optimizable.
- `static const` variables can be `constexpr`, usually.
- `static` function-local variables require an initialization check
every time the function is run.
Solution:
- If a global `static` variable is only used in a single function then
move it into the function and make it non-`static` and `constexpr`.
- Make all global `static` variables `constexpr` instead of `const`.
- Change function-local `static const[expr]` variables to be just
`constexpr`.
Diffstat (limited to 'Userland/Libraries/LibGfx/Painter.cpp')
-rw-r--r-- | Userland/Libraries/LibGfx/Painter.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Userland/Libraries/LibGfx/Painter.cpp b/Userland/Libraries/LibGfx/Painter.cpp index 89bec0cf58..1ccbbdcf43 100644 --- a/Userland/Libraries/LibGfx/Painter.cpp +++ b/Userland/Libraries/LibGfx/Painter.cpp @@ -1476,7 +1476,7 @@ void do_draw_text(const IntRect& rect, const TextType& text, const Font& font, T lines.append(line); } - static const int line_spacing = 4; + constexpr int line_spacing = 4; int line_height = font.glyph_height() + line_spacing; IntRect bounding_rect { 0, 0, 0, (static_cast<int>(lines.size()) * line_height) - line_spacing }; |