mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 02:27:35 +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:
parent
31515a9147
commit
f912a48315
23 changed files with 111 additions and 82 deletions
|
@ -1,9 +1,11 @@
|
|||
/*
|
||||
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2022, the SerenityOS developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/Array.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibCore/ConfigFile.h>
|
||||
|
@ -178,7 +180,10 @@ Icon FileIconProvider::icon_for_executable(const String& path)
|
|||
int image_size;
|
||||
};
|
||||
|
||||
static const IconSection icon_sections[] = { { .section_name = "serenity_icon_s", .image_size = 16 }, { .section_name = "serenity_icon_m", .image_size = 32 } };
|
||||
static constexpr Array<IconSection, 2> icon_sections = {
|
||||
IconSection { .section_name = "serenity_icon_s", .image_size = 16 },
|
||||
IconSection { .section_name = "serenity_icon_m", .image_size = 32 }
|
||||
};
|
||||
|
||||
bool had_error = false;
|
||||
for (const auto& icon_section : icon_sections) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue