From d7f9529bdd8b24701f8c1c2e62a52c8a7e908137 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Fri, 10 Jul 2015 18:01:56 -0300 Subject: Common: Fix mask generation in BitField Fixes #913 --- src/common/bit_field.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/common') diff --git a/src/common/bit_field.h b/src/common/bit_field.h index 1f3ecf84..257d5577 100644 --- a/src/common/bit_field.h +++ b/src/common/bit_field.h @@ -188,7 +188,7 @@ private: __forceinline StorageType GetMask() const { - return ((~(StorageTypeU)0) >> (8 * sizeof(T)-bits)) << position; + return (((StorageTypeU)~0) >> (8 * sizeof(T)-bits)) << position; } StorageType storage; -- cgit v1.2.3 From d5b52805014f537082afae79dc212958295ca9dc Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Fri, 10 Jul 2015 18:02:56 -0300 Subject: Common: Remove redundant masking in BitField For the signed case, the shifts already remove the rest of the value, so ANDing by the mask is redundant. --- src/common/bit_field.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/common') diff --git a/src/common/bit_field.h b/src/common/bit_field.h index 257d5577..3bc53500 100644 --- a/src/common/bit_field.h +++ b/src/common/bit_field.h @@ -160,7 +160,7 @@ public: if (std::numeric_limits::is_signed) { std::size_t shift = 8 * sizeof(T)-bits; - return (T)(((storage & GetMask()) << (shift - position)) >> shift); + return (T)((storage << (shift - position)) >> shift); } else { -- cgit v1.2.3