diff data/model/EditableDenseThreeDimensionalModel.cpp @ 593:4f3e3fb07e0b

* Make expandAndRetrieve much faster for cases with duplicated data being compressed at the start of a column (as is common in e.g. adaptive spectrogram output)
author Chris Cannam
date Thu, 21 May 2009 16:54:43 +0000
parents 3cc4b7cd2aa5
children 1415e35881f6
line wrap: on
line diff
--- a/data/model/EditableDenseThreeDimensionalModel.cpp	Mon May 18 10:24:36 2009 +0000
+++ b/data/model/EditableDenseThreeDimensionalModel.cpp	Thu May 21 16:54:43 2009 +0000
@@ -300,9 +300,18 @@
             c.push_back(p.at(i));
         }
     } else {
-        for (int i = psize - csize - 1; i >= 0; --i) {
-            c.push_front(p.at(i));
+        // push_front is very slow on QVector -- but not enough to
+        // make it desirable to choose a different container, since
+        // QVector has all the other advantages for us.  easier to
+        // write the whole array out to a new vector
+        Column cc(psize);
+        for (int i = 0; i < psize - csize; ++i) {
+            cc[i] = p.at(i);
         }
+        for (int i = 0; i < csize; ++i) {
+            cc[i + (psize - csize)] = c.at(i);
+        }
+        return cc;
     }
     return c;
 }
@@ -340,7 +349,7 @@
 
     truncateAndStore(index, values);
 
-    assert(values == expandAndRetrieve(index));
+//    assert(values == expandAndRetrieve(index));
 
     long windowStart = index;
     windowStart *= m_resolution;