From d3e4ab30720c48d0c019fa521d70362b1bdd2bae Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 15 Nov 2022 08:54:09 -0800 Subject: Prefer `constexpr` over `static const`. NFC (#2065) IIUC this is preferred in modern C++ and expresses indent better. --- include/wabt/interp/interp.h | 8 ++++---- include/wabt/interp/istream.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'include/wabt/interp') diff --git a/include/wabt/interp/interp.h b/include/wabt/interp/interp.h index 6d4a6a01..bb3cf487 100644 --- a/include/wabt/interp/interp.h +++ b/include/wabt/interp/interp.h @@ -96,7 +96,7 @@ enum class ObjectKind { Last = Instance, }; -static const int kCommandTypeCount = WABT_ENUM_COUNT(ObjectKind); +constexpr int kCommandTypeCount = WABT_ENUM_COUNT(ObjectKind); const char* GetName(Mutability); const std::string GetName(ValueType); @@ -119,7 +119,7 @@ using RefVec = std::vector; template struct Simd { using LaneType = T; - static const u8 lanes = L; + static constexpr u8 lanes = L; T v[L]; @@ -1086,8 +1086,8 @@ enum class RunResult { class Thread { public: struct Options { - static const u32 kDefaultValueStackSize = 64 * 1024 / sizeof(Value); - static const u32 kDefaultCallStackSize = 64 * 1024 / sizeof(Frame); + static constexpr u32 kDefaultValueStackSize = 64 * 1024 / sizeof(Value); + static constexpr u32 kDefaultCallStackSize = 64 * 1024 / sizeof(Frame); u32 value_stack_size = kDefaultValueStackSize; u32 call_stack_size = kDefaultCallStackSize; diff --git a/include/wabt/interp/istream.h b/include/wabt/interp/istream.h index 06e1cfca..f8eb6a26 100644 --- a/include/wabt/interp/istream.h +++ b/include/wabt/interp/istream.h @@ -95,7 +95,7 @@ class Istream { public: using SerializedOpcode = u32; // TODO: change to u16 using Offset = u32; - static const Offset kInvalidOffset = ~0; + static constexpr Offset kInvalidOffset = ~0; // Each br_table entry is made up of three instructions: // // interp_drop_keep $drop $keep @@ -103,7 +103,7 @@ class Istream { // br $label // // Each opcode is a SerializedOpcode, and each immediate is a u32. - static const Offset kBrTableEntrySize = + static constexpr Offset kBrTableEntrySize = sizeof(SerializedOpcode) * 3 + 4 * sizeof(u32); // Emit API. -- cgit v1.2.3