aboutsummaryrefslogtreecommitdiffstats
path: root/chilbert/SmallBitVec.hpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-08-19 17:59:20 +0200
committerDavid Robillard <d@drobilla.net>2018-09-29 14:49:56 +0200
commit7567f77828ff9661f85eabe3b4cfb1876b307d42 (patch)
tree82c44086cd8a8ed7025b342d5e3edd1add6ea1e0 /chilbert/SmallBitVec.hpp
parentc48d56bcc0c919007d712d8716c86714e387554b (diff)
downloadchilbert-7567f77828ff9661f85eabe3b4cfb1876b307d42.tar.gz
chilbert-7567f77828ff9661f85eabe3b4cfb1876b307d42.tar.bz2
chilbert-7567f77828ff9661f85eabe3b4cfb1876b307d42.zip
Remove old macros
Diffstat (limited to 'chilbert/SmallBitVec.hpp')
-rw-r--r--chilbert/SmallBitVec.hpp19
1 files changed, 3 insertions, 16 deletions
diff --git a/chilbert/SmallBitVec.hpp b/chilbert/SmallBitVec.hpp
index 96652e9..308d943 100644
--- a/chilbert/SmallBitVec.hpp
+++ b/chilbert/SmallBitVec.hpp
@@ -29,17 +29,6 @@
namespace chilbert {
-/* This must be an unsigned integer that is either 32 or 64 bits. Otherwise,
- there are places in the code that simply will not work. For speed, this
- should be the native word size. */
-typedef uint64_t FBV_UINT;
-
-#define FBV_BITS 64
-
-#define FBV1 (FBV_UINT{1})
-#define FBV1S (~FBV_UINT{0})
-#define FBVN1S(n) (n == FBV_BITS ? FBV1S : (FBV1 << n) - 1)
-
/** A bit vector small enough to fit in a single word. */
class SmallBitVec
{
@@ -100,7 +89,7 @@ public:
/// Set all bits to one
SmallBitVec& set()
{
- m_rack = FBV1S & FBVN1S(size());
+ m_rack = ~Rack{0} >> (bits_per_rack - m_size);
return *this;
}
@@ -221,9 +210,8 @@ public:
{
if (bits > 0 && bits < size()) {
assert(bits <= bits_per_rack);
- m_rack &= FBVN1S(size());
m_rack = (m_rack >> bits) | (m_rack << (size() - bits));
- m_rack &= FBVN1S(size());
+ m_rack &= (~Rack{0} >> (bits_per_rack - size()));
}
return *this;
}
@@ -233,9 +221,8 @@ public:
{
if (bits > 0 && bits < size()) {
assert(bits <= bits_per_rack);
- m_rack &= FBVN1S(size());
m_rack = (m_rack << bits) | (m_rack >> (size() - bits));
- m_rack &= FBVN1S(size());
+ m_rack &= (~Rack{0} >> (bits_per_rack - size()));
}
return *this;
}