diff options
author | Lenny Maiorani <lenny@colorado.edu> | 2021-05-19 08:35:09 -0600 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-05-19 21:21:47 +0100 |
commit | 57513271956942bbe51b39afeb4bb445aaff21fb (patch) | |
tree | 38fb1fc2a13b8f8d7538a214195bee6936d2da24 /Kernel/Net/NE2000NetworkAdapter.cpp | |
parent | 2b64d163cd9f25bd2951bf8721ef9325decb1b72 (diff) | |
download | serenity-57513271956942bbe51b39afeb4bb445aaff21fb.zip |
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`.
Diffstat (limited to 'Kernel/Net/NE2000NetworkAdapter.cpp')
-rw-r--r-- | Kernel/Net/NE2000NetworkAdapter.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Kernel/Net/NE2000NetworkAdapter.cpp b/Kernel/Net/NE2000NetworkAdapter.cpp index 74e6133808..10e39549ea 100644 --- a/Kernel/Net/NE2000NetworkAdapter.cpp +++ b/Kernel/Net/NE2000NetworkAdapter.cpp @@ -137,7 +137,7 @@ struct [[gnu::packed]] received_packet_header { UNMAP_AFTER_INIT void NE2000NetworkAdapter::detect() { - static const auto ne2k_ids = Array<PCI::ID, 11> { + constexpr auto ne2k_ids = Array { PCI::ID { 0x10EC, 0x8029 }, // RealTek RTL-8029(AS) // List of clones, taken from Linux's ne2k-pci.c |