changeset 108:1e7ab0399852

* marginal performance improvement through use of reserve() in PluginHostAdapter::convertFeatures
author cannam
date Fri, 08 Feb 2008 10:50:31 +0000
parents bbe67d59b427
children 9830daccee4b
files vamp-sdk/PluginAdapter.cpp vamp-sdk/PluginHostAdapter.cpp
diffstat 2 files changed, 17 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/vamp-sdk/PluginAdapter.cpp	Fri Feb 08 10:33:33 2008 +0000
+++ b/vamp-sdk/PluginAdapter.cpp	Fri Feb 08 10:50:31 2008 +0000
@@ -537,9 +537,9 @@
 
 VampFeatureList *
 PluginAdapterBase::Impl::vampProcess(VampPluginHandle handle,
-                               const float *const *inputBuffers,
-                               int sec,
-                               int nsec)
+                                     const float *const *inputBuffers,
+                                     int sec,
+                                     int nsec)
 {
 #ifdef DEBUG_PLUGIN_ADAPTER
     std::cerr << "PluginAdapterBase::Impl::vampProcess(" << handle << ", " << sec << ", " << nsec << ")" << std::endl;
@@ -686,8 +686,8 @@
     
 VampFeatureList *
 PluginAdapterBase::Impl::process(Plugin *plugin,
-                           const float *const *inputBuffers,
-                           int sec, int nsec)
+                                 const float *const *inputBuffers,
+                                 int sec, int nsec)
 {
 //    std::cerr << "PluginAdapterBase::Impl::process" << std::endl;
     RealTime rt(sec, nsec);
--- a/vamp-sdk/PluginHostAdapter.cpp	Fri Feb 08 10:33:33 2008 +0000
+++ b/vamp-sdk/PluginHostAdapter.cpp	Fri Feb 08 10:50:31 2008 +0000
@@ -394,9 +394,11 @@
 
         if (list.featureCount > 0) {
 
+            Feature feature;
+            feature.values.reserve(list.features[0].valueCount);
+
             for (unsigned int j = 0; j < list.featureCount; ++j) {
-                
-                Feature feature;
+
                 feature.hasTimestamp = list.features[j].hasTimestamp;
                 feature.timestamp = RealTime(list.features[j].sec,
                                              list.features[j].nsec);
@@ -410,6 +412,14 @@
                 }
 
                 fs[i].push_back(feature);
+
+                if (list.features[j].valueCount > 0) {
+                    feature.values.clear();
+                }
+
+                if (list.features[j].label) {
+                    feature.label = "";
+                }
             }
         }
     }