diff --git a/common/internal/BUILD b/common/internal/BUILD index 16ddc55b9..94f9a083d 100644 --- a/common/internal/BUILD +++ b/common/internal/BUILD @@ -83,6 +83,7 @@ cc_library( "@com_google_absl//absl/base:core_headers", "@com_google_absl//absl/functional:overload", "@com_google_absl//absl/log:absl_check", + "@com_google_absl//absl/meta:type_traits", "@com_google_absl//absl/strings:cord", "@com_google_absl//absl/strings:string_view", ], diff --git a/common/internal/shared_byte_string.h b/common/internal/shared_byte_string.h index d6a3f2949..741cc5183 100644 --- a/common/internal/shared_byte_string.h +++ b/common/internal/shared_byte_string.h @@ -27,6 +27,7 @@ #include "absl/base/optimization.h" #include "absl/functional/overload.h" #include "absl/log/absl_check.h" +#include "absl/meta/type_traits.h" #include "absl/strings/cord.h" #include "absl/strings/string_view.h" #include "common/internal/arena_string.h" @@ -34,7 +35,19 @@ namespace cel::common_internal { -constexpr bool IsStringLiteral(absl::string_view string); +inline constexpr bool IsStringLiteral(absl::string_view string) { +#ifdef ABSL_HAVE_CONSTANT_EVALUATED + if (!absl::is_constant_evaluated()) { + return false; + } +#endif + for (const auto& c : string) { + if (c == '\0') { + return false; + } + } + return true; +} inline constexpr uintptr_t kByteStringReferenceCountPooledBit = uintptr_t{1} << 0;