Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cel::common_internal::IsStringLiteral #614

Merged
1 commit merged into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions common/internal/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
Expand Down
15 changes: 14 additions & 1 deletion common/internal/shared_byte_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,27 @@
#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"
#include "common/internal/reference_count.h"

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;
Expand Down