From 7460d4432600b8d7e70254c11c28b71d19e30c82 Mon Sep 17 00:00:00 2001 From: Vladislav Shchapov Date: Wed, 5 Jan 2022 03:13:41 +0500 Subject: [PATCH] Turn 8 into a constant --- include/fmt/chrono.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index 07115c5c..682efd8d 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -558,12 +558,14 @@ inline void write_digit2_separated(char* buf, unsigned a, unsigned b, auto usep = static_cast(sep); // Add ASCII '0' to each digit byte and insert separators. digits |= 0x3030003030003030 | (usep << 16) | (usep << 40); + + constexpr const size_t len = 8; if (const_check(is_big_endian())) { - char tmp[8]; - memcpy(tmp, &digits, 8); - std::reverse_copy(tmp, tmp + 8, buf); + char tmp[len]; + memcpy(tmp, &digits, len); + std::reverse_copy(tmp, tmp + len, buf); } else { - memcpy(buf, &digits, 8); + memcpy(buf, &digits, len); } }