diff base/ResizeableBitset.h @ 183:146eb9e35baa

* Improve output from Profiler class and make it incur less (no) overhead in release builds with NO_TIMING defined * Fix a lock contention issue in spectrogram * Marginal optimisations elsewhere
author Chris Cannam
date Tue, 10 Oct 2006 14:51:17 +0000
parents 4ab844784152
children 95391b480e17
line wrap: on
line diff
--- a/base/ResizeableBitset.h	Mon Oct 09 10:49:46 2006 +0000
+++ b/base/ResizeableBitset.h	Tue Oct 10 14:51:17 2006 +0000
@@ -25,7 +25,7 @@
     ResizeableBitset() : m_bits(0) {
     }
     ResizeableBitset(size_t size) : m_bits(new std::vector<uint8_t>) {
-        m_bits->assign(size / 8 + 1, 0);
+        m_bits->assign((size >> 3) + 1, 0);
     }
     ResizeableBitset(const ResizeableBitset &b) {
         m_bits = new std::vector<uint8_t>(*b.m_bits);
@@ -45,19 +45,19 @@
             delete m_bits;
             m_bits = new std::vector<uint8_t>;
         }
-        m_bits->assign(bits / 8 + 1, 0);
+        m_bits->assign((bits >> 3) + 1, 0);
     }
     
     bool get(size_t column) const {
-        return ((*m_bits)[column / 8]) & (1u << (column % 8));
+        return ((*m_bits)[column >> 3]) & (1u << (column & 0x07));
     }
     
     void set(size_t column) {
-        ((*m_bits)[column / 8]) |=  (uint8_t(1) << (column % 8));
+        ((*m_bits)[column >> 3]) |=  (uint8_t(1) << (column & 0x07));
     }
 
     void reset(size_t column) {
-        ((*m_bits)[column / 8]) &= ~(uint8_t(1) << (column % 8));
+        ((*m_bits)[column >> 3]) &= ~(uint8_t(1) << (column & 0x07));
     }
 
     void copy(size_t source, size_t dest) {