mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-30 10:47:35 +02:00
Get rid of unnecessary recursion to enable inlining
This commit is contained in:
@ -1482,16 +1482,21 @@ OutputIt write_bytes(OutputIt out, string_view bytes,
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Char, typename OutputIt>
|
template <typename Char, typename OutputIt>
|
||||||
FMT_CONSTEXPR OutputIt write(OutputIt out, Char value,
|
FMT_CONSTEXPR OutputIt write_char(OutputIt out, Char value,
|
||||||
const basic_format_specs<Char>& specs,
|
const basic_format_specs<Char>& specs) {
|
||||||
locale_ref loc = {}) {
|
|
||||||
if (specs.type && specs.type != 'c')
|
|
||||||
return write(out, static_cast<int>(value), specs, loc);
|
|
||||||
return write_padded(out, specs, 1, [=](reserve_iterator<OutputIt> it) {
|
return write_padded(out, specs, 1, [=](reserve_iterator<OutputIt> it) {
|
||||||
*it++ = value;
|
*it++ = value;
|
||||||
return it;
|
return it;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
template <typename Char, typename OutputIt>
|
||||||
|
FMT_CONSTEXPR OutputIt write(OutputIt out, Char value,
|
||||||
|
const basic_format_specs<Char>& specs,
|
||||||
|
locale_ref loc = {}) {
|
||||||
|
return !specs.type || specs.type == 'c'
|
||||||
|
? write_char(out, value, specs)
|
||||||
|
: write(out, static_cast<int>(value), specs, loc);
|
||||||
|
}
|
||||||
|
|
||||||
// Data for write_int that doesn't depend on output iterator type. It is used to
|
// Data for write_int that doesn't depend on output iterator type. It is used to
|
||||||
// avoid template code bloat.
|
// avoid template code bloat.
|
||||||
@ -1662,7 +1667,7 @@ FMT_CONSTEXPR OutputIt write(OutputIt out, T value,
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
case 'c':
|
case 'c':
|
||||||
return write<Char>(out, static_cast<Char>(abs_value), specs);
|
return write_char(out, static_cast<Char>(abs_value), specs);
|
||||||
default:
|
default:
|
||||||
FMT_THROW(format_error("invalid type specifier"));
|
FMT_THROW(format_error("invalid type specifier"));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user