diff data/model/Dense3DModelPeakCache.cpp @ 1153:ece369c5bb68 3.0-integration

Don't need ResizeableBitset, vector<bool> is already a compact format
author Chris Cannam
date Fri, 22 Jan 2016 12:46:42 +0000
parents 59e7fe1b1003
children 546d4e417346
line wrap: on
line diff
--- a/data/model/Dense3DModelPeakCache.cpp	Fri Jan 22 12:46:19 2016 +0000
+++ b/data/model/Dense3DModelPeakCache.cpp	Fri Jan 22 12:46:42 2016 +0000
@@ -22,8 +22,6 @@
     m_source(source),
     m_resolution(columnsPerPeak)
 {
-    m_coverage.resize(1); // otherwise it is simply invalid
-
     m_cache = new EditableDenseThreeDimensionalModel
         (source->getSampleRate(),
          getResolution(),
@@ -81,9 +79,9 @@
     if (m_coverage.size() > 0) {
         // The last peak may have come from an incomplete read, which
         // may since have been filled, so reset it
-        m_coverage.reset(m_coverage.size()-1);
+        m_coverage[m_coverage.size()-1] = false;
     }
-    m_coverage.resize(getWidth()); // retaining data
+    m_coverage.resize(getWidth(), false); // retaining data
 }
 
 void
@@ -95,7 +93,7 @@
 bool
 Dense3DModelPeakCache::haveColumn(int column) const
 {
-    return column < (int)m_coverage.size() && m_coverage.get(column);
+    return in_range_for(m_coverage, column) && m_coverage[column];
 }
 
 void
@@ -103,26 +101,26 @@
 {
     Profiler profiler("Dense3DModelPeakCache::fillColumn");
 
-    if (column >= (int)m_coverage.size()) {
+    if (!in_range_for(m_coverage, column)) {
         // see note in sourceModelChanged
-        if (m_coverage.size() > 0) m_coverage.reset(m_coverage.size()-1);
-        m_coverage.resize(column + 1);
+        if (m_coverage.size() > 0) m_coverage[m_coverage.size()-1] = false;
+        m_coverage.resize(column + 1, false);
     }
 
     Column peak;
-    for (int i = 0; i < int(m_resolution); ++i) {
+    for (int i = 0; i < m_resolution; ++i) {
         Column here = m_source->getColumn(column * m_resolution + i);
         if (i == 0) {
             peak = here;
         } else {
-            for (int j = 0; j < (int)peak.size() && j < (int)here.size(); ++j) {
+            for (int j = 0; in_range_for(peak, j) && in_range_for(here, j); ++j) {
                 if (here[j] > peak[j]) peak[j] = here[j];
             }
         }
     }
 
     m_cache->setColumn(column, peak);
-    m_coverage.set(column);
+    m_coverage[column] = true;
 }