Optimize parsing of argument ids
This commit is contained in:
parent
6a9016ea60
commit
87c5cd46ac
@ -121,8 +121,8 @@ FMT_END_NAMESPACE
|
||||
# define FMT_THROW(x) throw x
|
||||
# endif
|
||||
# else
|
||||
# define FMT_THROW(x) \
|
||||
do { \
|
||||
# define FMT_THROW(x) \
|
||||
do { \
|
||||
FMT_ASSERT(false, (x).what()); \
|
||||
} while (false)
|
||||
# endif
|
||||
@ -2847,14 +2847,10 @@ class dynamic_specs_handler
|
||||
};
|
||||
|
||||
template <typename Char, typename IDHandler>
|
||||
FMT_CONSTEXPR const Char* parse_arg_id(const Char* begin, const Char* end,
|
||||
IDHandler&& handler) {
|
||||
FMT_CONSTEXPR const Char* do_parse_arg_id(const Char* begin, const Char* end,
|
||||
IDHandler&& handler) {
|
||||
FMT_ASSERT(begin != end, "");
|
||||
Char c = *begin;
|
||||
if (c == '}' || c == ':') {
|
||||
handler();
|
||||
return begin;
|
||||
}
|
||||
if (c >= '0' && c <= '9') {
|
||||
int index = 0;
|
||||
if (c != '0')
|
||||
@ -2879,6 +2875,16 @@ FMT_CONSTEXPR const Char* parse_arg_id(const Char* begin, const Char* end,
|
||||
return it;
|
||||
}
|
||||
|
||||
template <typename Char, typename IDHandler>
|
||||
FMT_CONSTEXPR_DECL FMT_INLINE const Char* parse_arg_id(const Char* begin,
|
||||
const Char* end,
|
||||
IDHandler&& handler) {
|
||||
Char c = *begin;
|
||||
if (c != '}' && c != ':') return do_parse_arg_id(begin, end, handler);
|
||||
handler();
|
||||
return begin;
|
||||
}
|
||||
|
||||
// Adapts SpecHandler to IDHandler API for dynamic width.
|
||||
template <typename SpecHandler, typename Char> struct width_adapter {
|
||||
explicit FMT_CONSTEXPR width_adapter(SpecHandler& h) : handler(h) {}
|
||||
|
Loading…
Reference in New Issue
Block a user