forked from fmtlib/fmt
Cleanup parse_format_string
This commit is contained in:
@ -2591,21 +2591,21 @@ FMT_CONSTEXPR FMT_INLINE void parse_format_string(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
struct writer {
|
struct writer {
|
||||||
FMT_CONSTEXPR void operator()(const Char* pbegin, const Char* pend) {
|
FMT_CONSTEXPR void operator()(const Char* from, const Char* to) {
|
||||||
if (pbegin == pend) return;
|
if (from == to) return;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
const Char* p = nullptr;
|
const Char* p = nullptr;
|
||||||
if (!find<IS_CONSTEXPR>(pbegin, pend, Char('}'), p))
|
if (!find<IS_CONSTEXPR>(from, to, Char('}'), p))
|
||||||
return handler_.on_text(pbegin, pend);
|
return handler_.on_text(from, to);
|
||||||
++p;
|
++p;
|
||||||
if (p == pend || *p != '}')
|
if (p == to || *p != '}')
|
||||||
return handler_.on_error("unmatched '}' in format string");
|
return handler_.on_error("unmatched '}' in format string");
|
||||||
handler_.on_text(pbegin, p);
|
handler_.on_text(from, p);
|
||||||
pbegin = p + 1;
|
from = p + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Handler& handler_;
|
Handler& handler_;
|
||||||
} write{handler};
|
} write = {handler};
|
||||||
while (begin != end) {
|
while (begin != end) {
|
||||||
// Doing two passes with memchr (one for '{' and another for '}') is up to
|
// Doing two passes with memchr (one for '{' and another for '}') is up to
|
||||||
// 2.5x faster than the naive one-pass implementation on big format strings.
|
// 2.5x faster than the naive one-pass implementation on big format strings.
|
||||||
@ -2620,7 +2620,6 @@ FMT_CONSTEXPR FMT_INLINE void parse_format_string(
|
|||||||
template <typename T, bool = is_named_arg<T>::value> struct strip_named_arg {
|
template <typename T, bool = is_named_arg<T>::value> struct strip_named_arg {
|
||||||
using type = T;
|
using type = T;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T> struct strip_named_arg<T, true> {
|
template <typename T> struct strip_named_arg<T, true> {
|
||||||
using type = remove_cvref_t<decltype(T::value)>;
|
using type = remove_cvref_t<decltype(T::value)>;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user