From 97377ac82a909b7d81537f5968381ea6af367a94 Mon Sep 17 00:00:00 2001 From: Yedidya Feldblum Date: Thu, 2 Mar 2017 21:32:09 -0800 Subject: [PATCH] Tweak size handling in Endian Summary: [Folly] Tweak size handling in `Endian`. Either multiply by 8 in one place, or divide by 8 in another place. Go with the latter, because `sizeof` in C++ emits byte sizes, not bit sizes. Reviewed By: simpkins Differential Revision: D4645020 fbshipit-source-id: cb78600ba4c20bebc66aed506d4b5d6c378fc998 --- folly/Bits.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/folly/Bits.h b/folly/Bits.h index 6c3c30ec..b818655e 100644 --- a/folly/Bits.h +++ b/folly/Bits.h @@ -241,7 +241,7 @@ struct uint_types_by_size; return fn(v); \ } \ template <> \ - struct uint_types_by_size { \ + struct uint_types_by_size { \ using type = uint##sz##_t; \ }; @@ -268,7 +268,7 @@ struct EndianInt { // we implement this with memcpy because that is defined behavior in C++ // we rely on compilers to optimize away the memcpy calls constexpr auto s = sizeof(T); - using B = typename uint_types_by_size<8 * s>::type; + using B = typename uint_types_by_size::type; B b; std::memcpy(&b, &x, s); b = byteswap_gen(b); -- 2.34.1