mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-15 23:09:05 +00:00
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`.
This commit is contained in:
parent
17ff895e1c
commit
800ea8ea96
Notes:
sideshowbarker
2024-07-18 17:38:29 +09:00
Author: https://github.com/ldm5180
Commit: 800ea8ea96
Pull-request: https://github.com/SerenityOS/serenity/pull/7318
Reviewed-by: https://github.com/IdanHo
38 changed files with 192 additions and 184 deletions
|
@ -37,7 +37,7 @@
|
|||
namespace JS {
|
||||
|
||||
// Used in various abstract operations to make it obvious when a non-optional return value must be discarded.
|
||||
static const double INVALID { 0 };
|
||||
static constexpr double INVALID { 0 };
|
||||
|
||||
static inline bool same_type_for_equality(const Value& lhs, const Value& rhs)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue