Use memcpy in more cases in copy2
This commit is contained in:
parent
e47e99bb09
commit
04e3a79f76
@ -1051,16 +1051,12 @@ inline auto equal2(const char* lhs, const char* rhs) -> bool {
|
|||||||
// Copies two characters from src to dst.
|
// Copies two characters from src to dst.
|
||||||
template <typename Char>
|
template <typename Char>
|
||||||
FMT_CONSTEXPR20 FMT_INLINE void copy2(Char* dst, const char* src) {
|
FMT_CONSTEXPR20 FMT_INLINE void copy2(Char* dst, const char* src) {
|
||||||
if (!is_constant_evaluated() && std::is_same<Char, char>::value) {
|
if (!is_constant_evaluated() && sizeof(Char) == sizeof(char)) {
|
||||||
memcpy(dst, src, 2);
|
memcpy(dst, src, 2);
|
||||||
} else {
|
return;
|
||||||
// We read both bytes before writing so that the compiler can do it in
|
|
||||||
// one pair of read/write instructions (even if Char aliases char)
|
|
||||||
char dc0 = *src++;
|
|
||||||
char dc1 = *src;
|
|
||||||
*dst++ = static_cast<Char>(dc0);
|
|
||||||
*dst = static_cast<Char>(dc1);
|
|
||||||
}
|
}
|
||||||
|
*dst++ = static_cast<Char>(*src++);
|
||||||
|
*dst = static_cast<Char>(*src);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Iterator> struct format_decimal_result {
|
template <typename Iterator> struct format_decimal_result {
|
||||||
|
Loading…
Reference in New Issue
Block a user