From 12a311e287719abac8b8690d726a6cba6d635113 Mon Sep 17 00:00:00 2001 From: Kelly Kinkade Date: Mon, 24 Nov 2025 00:12:43 -0600 Subject: [PATCH 1/2] use `constexpr` in `Core` where possible --- library/Core.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/library/Core.cpp b/library/Core.cpp index 33f66d767e..99919099db 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -201,7 +201,7 @@ uint32_t PerfCounters::getUnpausedFps() { struct CommandDepthCounter { - static const int MAX_DEPTH = 20; + static constexpr int MAX_DEPTH = 20; static thread_local int depth; CommandDepthCounter() { depth++; } ~CommandDepthCounter() { depth--; } @@ -902,8 +902,8 @@ command_result Core::runCommand(color_ostream &con, const std::string &first_, s } else if (first == "plug") { - const char *header_format = "%30s %10s %4s %8s\n"; - const char *row_format = "%30s %10s %4i %8s\n"; + constexpr auto header_format = "%30s %10s %4s %8s\n"; + constexpr auto row_format = "%30s %10s %4i %8s\n"; con.print(header_format, "Name", "State", "Cmds", "Enabled"); plug_mgr->refresh(); @@ -1601,7 +1601,7 @@ bool Core::InitMainThread() { { if (!Version::git_xml_match()) { - const char *msg = ( + constexpr auto msg = ( "*******************************************************\n" "* BIG, UGLY ERROR MESSAGE *\n" "*******************************************************\n" @@ -2166,7 +2166,7 @@ static void getFilesWithPrefixAndSuffix(const std::filesystem::path& folder, con } size_t loadScriptFiles(Core* core, color_ostream& out, const std::span prefix, const std::filesystem::path& folder) { - static const std::string suffix = ".init"; + static constexpr std::string suffix = ".init"; std::vector scriptFiles; for ( const auto& p : prefix ) { getFilesWithPrefixAndSuffix(folder, p, ".init", scriptFiles); From 61d8540fc6e041e4f78a99f8544746525457c020 Mon Sep 17 00:00:00 2001 From: Kelly Kinkade Date: Mon, 24 Nov 2025 00:42:54 -0600 Subject: [PATCH 2/2] fix row format, roll back one `constexpr` --- library/Core.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/Core.cpp b/library/Core.cpp index 99919099db..bb631414c6 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -903,7 +903,7 @@ command_result Core::runCommand(color_ostream &con, const std::string &first_, s else if (first == "plug") { constexpr auto header_format = "%30s %10s %4s %8s\n"; - constexpr auto row_format = "%30s %10s %4i %8s\n"; + constexpr auto row_format = "%30s %10s %4zu %8s\n"; con.print(header_format, "Name", "State", "Cmds", "Enabled"); plug_mgr->refresh(); @@ -2166,7 +2166,7 @@ static void getFilesWithPrefixAndSuffix(const std::filesystem::path& folder, con } size_t loadScriptFiles(Core* core, color_ostream& out, const std::span prefix, const std::filesystem::path& folder) { - static constexpr std::string suffix = ".init"; + static const std::string suffix = ".init"; std::vector scriptFiles; for ( const auto& p : prefix ) { getFilesWithPrefixAndSuffix(folder, p, ".init", scriptFiles);