diff data/model/FFTModel.h @ 1371:fad8f533ca13

Reduce amount of copying in FFTModel
author Chris Cannam
date Thu, 26 Jan 2017 14:11:20 +0000
parents 54af1e21705c
children 0f62bce0f0be
line wrap: on
line diff
--- a/data/model/FFTModel.h	Fri Jan 20 18:05:41 2017 +0000
+++ b/data/model/FFTModel.h	Thu Jan 26 14:11:20 2017 +0000
@@ -27,7 +27,6 @@
 #include <set>
 #include <vector>
 #include <complex>
-#include <deque>
 
 /**
  * An implementation of DenseThreeDimensionalModel that makes FFT data
@@ -172,7 +171,7 @@
     typedef std::vector<std::complex<float>,
                         breakfastquay::StlAllocator<std::complex<float>>> cvec;
     
-    cvec getFFTColumn(int column) const;
+    const cvec &getFFTColumn(int column) const; // returns ref for immediate use only
     fvec getSourceSamples(int column) const;
     fvec getSourceData(std::pair<sv_frame_t, sv_frame_t>) const;
     fvec getSourceDataUncached(std::pair<sv_frame_t, sv_frame_t>) const;
@@ -182,12 +181,13 @@
         fvec data;
     };
     mutable SavedSourceData m_savedData;
-    
+
     struct SavedColumn {
         int n;
         cvec col;
     };
-    mutable std::deque<SavedColumn> m_cached;
+    mutable std::vector<SavedColumn> m_cached;
+    mutable size_t m_cacheWriteIndex;
     size_t m_cacheSize;
 };