@@ -64,32 +64,14 @@ struct _LIBCPP_TEMPLATE_VIS formatter<const _CharT*, _CharT> : public __formatte
64
64
template <class _FormatContext >
65
65
_LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format (const _CharT* __str, _FormatContext& __ctx) const {
66
66
_LIBCPP_ASSERT_INTERNAL (__str, " The basic_format_arg constructor should have prevented an invalid pointer." );
67
-
68
- __format_spec::__parsed_specifications<_CharT> __specs = _Base::__parser_.__get_parsed_std_specifications (__ctx);
69
- # if _LIBCPP_STD_VER >= 23
70
- if (_Base::__parser_.__type_ == __format_spec::__type::__debug)
71
- return __formatter::__format_escaped_string (basic_string_view<_CharT>{__str}, __ctx.out (), __specs);
72
- # endif
73
-
74
- // When using a center or right alignment and the width option the length
75
- // of __str must be known to add the padding upfront. This case is handled
76
- // by the base class by converting the argument to a basic_string_view.
67
+ // Converting the input to a basic_string_view means the data is looped over twice;
68
+ // - once to determine the length, and
69
+ // - once to process the data.
77
70
//
78
- // When using left alignment and the width option the padding is added
79
- // after outputting __str so the length can be determined while outputting
80
- // __str. The same holds true for the precision, during outputting __str it
81
- // can be validated whether the precision threshold has been reached. For
82
- // now these optimizations aren't implemented. Instead the base class
83
- // handles these options.
84
- // TODO FMT Implement these improvements.
85
- if (__specs.__has_width () || __specs.__has_precision ())
86
- return __formatter::__write_string (basic_string_view<_CharT>{__str}, __ctx.out (), __specs);
87
-
88
- // No formatting required, copy the string to the output.
89
- auto __out_it = __ctx.out ();
90
- while (*__str)
91
- *__out_it++ = *__str++;
92
- return __out_it;
71
+ // This sounds slower than writing the output directly. However internally
72
+ // the output algorithms have optimizations for "bulk" operations, which
73
+ // makes this faster than a single-pass character-by-character output.
74
+ return _Base::format (basic_string_view<_CharT>(__str), __ctx);
93
75
}
94
76
};
95
77
0 commit comments