diff options
author | Jorg Brown <jorg@google.com> | 2022-12-02 07:27:34 -0800 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-12-02 07:28:27 -0800 |
commit | 7cbdff8c13503561a166438e45bc37c5c5d0066b (patch) | |
tree | bb19dd8a6ac84bc3332f9b8351f857e54ec6db6a | |
parent | 1063d2b829bbf1b5cf03f5f8e1e9fe4c71c9f966 (diff) |
Use a c++14-style constexpr initialization if c++14 constexpr is available.
PiperOrigin-RevId: 492463896
Change-Id: I063759ca5ceb3597a7c8ab25af23aa688dee26c2
-rw-r--r-- | absl/strings/internal/char_map.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/absl/strings/internal/char_map.h b/absl/strings/internal/char_map.h index 5aabc1fc..70a90343 100644 --- a/absl/strings/internal/char_map.h +++ b/absl/strings/internal/char_map.h @@ -73,10 +73,10 @@ class Charmap { } // Containing all the chars in the C-string 's'. - // Note that this is expensively recursive because of the C++11 constexpr - // formulation. Use only in constexpr initializers. static constexpr Charmap FromString(const char* s) { - return *s == 0 ? Charmap() : (Char(*s) | FromString(s + 1)); + Charmap ret; + while (*s) ret = ret | Char(*s++); + return ret; } // Containing all the chars in the closed interval [lo,hi]. |