[llvm] [Support] Simplify mapOptionalWithContext (NFC) (PR #137529)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 27 12:14:44 PDT 2025
================
@@ -901,11 +901,12 @@ class IO {
}
template <typename T, typename Context>
- std::enable_if_t<has_SequenceTraits<T>::value, void>
- mapOptionalWithContext(const char *Key, T &Val, Context &Ctx) {
- // omit key/value instead of outputting empty sequence
- if (this->canElideEmptySequence() && !(Val.begin() != Val.end()))
- return;
+ void mapOptionalWithContext(const char *Key, T &Val, Context &Ctx) {
+ if constexpr (has_SequenceTraits<T>::value) {
+ // omit key/value instead of outputting empty sequence
+ if (this->canElideEmptySequence() && !(Val.begin() != Val.end()))
----------------
nikic wrote:
```suggestion
if (this->canElideEmptySequence() && Val.begin() == Val.end())
```
While here? Unless there's some weird reason it has to be written that way...
https://github.com/llvm/llvm-project/pull/137529
More information about the llvm-commits
mailing list