mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09: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
Notes:
sideshowbarker
2024-07-17 17:10:24 +09:00
Author: https://github.com/ldm5180
Commit: f912a48315
Pull-request: https://github.com/SerenityOS/serenity/pull/13038
Reviewed-by: https://github.com/kleinesfilmroellchen ✅
23 changed files with 111 additions and 82 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2022, the SerenityOS developers.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -9,6 +10,7 @@
|
|||
#include <AK/JsonObject.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringUtils.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
#include <LibCore/File.h>
|
||||
|
@ -19,9 +21,9 @@
|
|||
static bool flag_show_numerical = false;
|
||||
static bool flag_verbose = false;
|
||||
|
||||
static const char* format_numerical = "{:04x}:{:02x}:{:02x}.{} {}: {}:{} (rev {:02x})";
|
||||
static const char* format_textual = "{:04x}:{:02x}:{:02x}.{} {}: {} {} (rev {:02x})";
|
||||
static const char* format_region = "\tBAR {}: {} region @ {:#x}";
|
||||
static constexpr StringView format_numerical = "{:04x}:{:02x}:{:02x}.{} {}: {}:{} (rev {:02x})";
|
||||
static constexpr StringView format_textual = "{:04x}:{:02x}:{:02x}.{} {}: {} {} (rev {:02x})";
|
||||
static constexpr StringView format_region = "\tBAR {}: {} region @ {:#x}";
|
||||
|
||||
static u32 read_hex_string_from_bytebuffer(ByteBuffer const& buf)
|
||||
{
|
||||
|
@ -50,7 +52,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
args_parser.add_option(flag_verbose, "Show verbose info on devices", "verbose", 'v');
|
||||
args_parser.parse(arguments);
|
||||
|
||||
const char* format = flag_show_numerical ? format_numerical : format_textual;
|
||||
auto const format = flag_show_numerical ? format_numerical : format_textual;
|
||||
|
||||
RefPtr<PCIDB::Database> db;
|
||||
if (!flag_show_numerical) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue