mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:47:35 +00:00
Kernel: 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
2b64d163cd
commit
5751327195
15 changed files with 30 additions and 37 deletions
|
@ -16,7 +16,7 @@ Atomic<bool> g_caps_lock_remapped_to_ctrl;
|
|||
static AK::Singleton<HIDManagement> s_the;
|
||||
|
||||
// clang-format off
|
||||
static const Keyboard::CharacterMapData DEFAULT_CHARACTER_MAP =
|
||||
static constexpr Keyboard::CharacterMapData DEFAULT_CHARACTER_MAP =
|
||||
{
|
||||
.map = {
|
||||
0, '\033', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 0x08,
|
||||
|
@ -74,10 +74,6 @@ static const Keyboard::CharacterMapData DEFAULT_CHARACTER_MAP =
|
|||
};
|
||||
// clang-format on
|
||||
|
||||
KeyboardClient::~KeyboardClient()
|
||||
{
|
||||
}
|
||||
|
||||
size_t HIDManagement::generate_minor_device_number_for_mouse()
|
||||
{
|
||||
// FIXME: Lock this to prevent race conditions with hot-plugging devices!
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue