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/LibRegex/RegexMatcher.h | |
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/LibRegex/RegexMatcher.h')
-rw-r--r-- | Userland/Libraries/LibRegex/RegexMatcher.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Libraries/LibRegex/RegexMatcher.h b/Userland/Libraries/LibRegex/RegexMatcher.h index 4be02b2ec1..c6a30ff7be 100644 --- a/Userland/Libraries/LibRegex/RegexMatcher.h +++ b/Userland/Libraries/LibRegex/RegexMatcher.h @@ -23,8 +23,8 @@ namespace regex { -static const constexpr size_t c_max_recursion = 5000; -static const constexpr size_t c_match_preallocation_count = 0; +static constexpr size_t c_max_recursion = 5000; +static constexpr size_t c_match_preallocation_count = 0; struct RegexResult final { bool success { false }; |