1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 06:27:45 +00:00

Userland: Change static const variables to static constexpr

`static const` variables can be computed and initialized at run-time
during initialization or the first time a function is called. Change
them to `static constexpr` to ensure they are computed at
compile-time.

This allows some removal of `strlen` because the length of the
`StringView` can be used which is pre-computed at compile-time.
This commit is contained in:
Lenny Maiorani 2022-03-13 16:09:41 -06:00 committed by Andreas Kling
parent 31515a9147
commit f912a48315
23 changed files with 111 additions and 82 deletions

View file

@ -23,6 +23,7 @@
* [ ] handle fire bitmap edges better
*/
#include <AK/Array.h>
#include <LibCore/ElapsedTimer.h>
#include <LibCore/System.h>
#include <LibGUI/Action.h>
@ -45,7 +46,7 @@
#define FIRE_HEIGHT 200
#define FIRE_MAX 29
static const Color s_palette[] = {
static constexpr Array<Color, 30> s_palette = {
Color(0x07, 0x07, 0x07), Color(0x1F, 0x07, 0x07), Color(0x2F, 0x0F, 0x07),
Color(0x47, 0x0F, 0x07), Color(0x57, 0x17, 0x07), Color(0x67, 0x1F, 0x07),
Color(0x77, 0x1F, 0x07), Color(0x9F, 0x2F, 0x07), Color(0xAF, 0x3F, 0x07),