From c334a6ca65b0515897a15d4135e9a2e561ba47ce Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sat, 11 Jul 2015 22:27:56 -0400 Subject: [PATCH 1/2] Common: Fix mask generation in BitField --- Source/Core/Common/BitField.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Common/BitField.h b/Source/Core/Common/BitField.h index 3b30a3cab0..14c03973ad 100644 --- a/Source/Core/Common/BitField.h +++ b/Source/Core/Common/BitField.h @@ -183,7 +183,7 @@ private: __forceinline StorageType GetMask() const { - return ((~(StorageTypeU)0) >> (8 * sizeof(T) - bits)) << position; + return (((StorageTypeU)~0) >> (8 * sizeof(T) - bits)) << position; } StorageType storage; From 5c264281ebe261f32fda1e1bc08a7fc46d768ed3 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sat, 11 Jul 2015 22:29:16 -0400 Subject: [PATCH 2/2] 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. --- Source/Core/Common/BitField.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Common/BitField.h b/Source/Core/Common/BitField.h index 14c03973ad..75a5b104fd 100644 --- a/Source/Core/Common/BitField.h +++ b/Source/Core/Common/BitField.h @@ -156,7 +156,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 {