From aacf84e552fd404c63ecea345a6e44953446ee51 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 22 Jan 2020 13:50:05 +0100 Subject: [PATCH] Type, util: add `constexpr` to static variables This allows the compiler to move them to section `.rodata`. --- src/Type.cc | 2 +- src/util.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Type.cc b/src/Type.cc index 43f5da6267..6a4139bc8b 100644 --- a/src/Type.cc +++ b/src/Type.cc @@ -19,7 +19,7 @@ BroType::TypeAliasMap BroType::type_aliases; // Note: This function must be thread-safe. const char* type_name(TypeTag t) { - static const char* type_names[int(NUM_TYPES)] = { + static constexpr const char* type_names[int(NUM_TYPES)] = { "void", // 0 "bool", // 1 "int", // 2 diff --git a/src/util.cc b/src/util.cc index 18999aa903..cbd635d5a2 100644 --- a/src/util.cc +++ b/src/util.cc @@ -612,7 +612,7 @@ TEST_CASE("util uitoa_n") char* uitoa_n(uint64_t value, char* str, int n, int base, const char* prefix) { - static char dig[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; + static constexpr char dig[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; assert(n);