From 6bf7dfc9753ab6afd5964b490cf24745a44c0d70 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 14 Jul 2022 12:23:57 -0700 Subject: [PATCH] Revert "Revert "[c++14] Simplify macro thats always the same now (#29601)" (#29784)" (#29785) This reverts commit 0eda91fa2822690e365ea5b78b4a8e4c28f86e80. --- src/core/lib/gprpp/bitset.h | 16 +++------------- src/core/lib/slice/percent_encoding.cc | 16 ++++------------ 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/src/core/lib/gprpp/bitset.h b/src/core/lib/gprpp/bitset.h index 8fcd44edcae..cb25a44635e 100644 --- a/src/core/lib/gprpp/bitset.h +++ b/src/core/lib/gprpp/bitset.h @@ -24,12 +24,6 @@ #include "src/core/lib/gpr/useful.h" -#if __cplusplus > 201103l -#define GRPC_BITSET_CONSTEXPR_MUTATOR constexpr -#else -#define GRPC_BITSET_CONSTEXPR_MUTATOR -#endif - namespace grpc_core { // Given a bit count as an integer, vend as member type `Type` a type with @@ -90,12 +84,10 @@ class BitSet { constexpr BitSet() : units_{} {} // Set bit i to true - GRPC_BITSET_CONSTEXPR_MUTATOR void set(int i) { - units_[unit_for(i)] |= mask_for(i); - } + constexpr void set(int i) { units_[unit_for(i)] |= mask_for(i); } // Set bit i to is_set - GRPC_BITSET_CONSTEXPR_MUTATOR void set(int i, bool is_set) { + constexpr void set(int i, bool is_set) { if (is_set) { set(i); } else { @@ -104,9 +96,7 @@ class BitSet { } // Set bit i to false - GRPC_BITSET_CONSTEXPR_MUTATOR void clear(int i) { - units_[unit_for(i)] &= ~mask_for(i); - } + constexpr void clear(int i) { units_[unit_for(i)] &= ~mask_for(i); } // Return true if bit i is set constexpr bool is_set(int i) const { diff --git a/src/core/lib/slice/percent_encoding.cc b/src/core/lib/slice/percent_encoding.cc index 6b69a0f54c3..8f912807437 100644 --- a/src/core/lib/slice/percent_encoding.cc +++ b/src/core/lib/slice/percent_encoding.cc @@ -30,20 +30,12 @@ #include "src/core/lib/gprpp/bitset.h" -#if __cplusplus > 201103l -#define GRPC_PCTENCODE_CONSTEXPR_FN constexpr -#define GRPC_PCTENCODE_CONSTEXPR_VALUE constexpr -#else -#define GRPC_PCTENCODE_CONSTEXPR_FN -#define GRPC_PCTENCODE_CONSTEXPR_VALUE const -#endif - namespace grpc_core { namespace { class UrlTable : public BitSet<256> { public: - GRPC_PCTENCODE_CONSTEXPR_FN UrlTable() { + constexpr UrlTable() { for (int i = 'a'; i <= 'z'; i++) set(i); for (int i = 'A'; i <= 'Z'; i++) set(i); for (int i = '0'; i <= '9'; i++) set(i); @@ -54,11 +46,11 @@ class UrlTable : public BitSet<256> { } }; -GRPC_PCTENCODE_CONSTEXPR_VALUE UrlTable g_url_table; +constexpr UrlTable g_url_table; class CompatibleTable : public BitSet<256> { public: - GRPC_PCTENCODE_CONSTEXPR_FN CompatibleTable() { + constexpr CompatibleTable() { for (int i = 32; i <= 126; i++) { if (i == '%') continue; set(i); @@ -66,7 +58,7 @@ class CompatibleTable : public BitSet<256> { } }; -GRPC_PCTENCODE_CONSTEXPR_VALUE CompatibleTable g_compatible_table; +constexpr CompatibleTable g_compatible_table; // Map PercentEncodingType to a lookup table of legal symbols for that encoding. const BitSet<256>& LookupTableForPercentEncodingType(PercentEncodingType type) {