From 3dc6d8df218031df0507bd8ed859dbcf387933bc Mon Sep 17 00:00:00 2001 From: w1z7ard Date: Tue, 9 Oct 2007 01:03:14 +0000 Subject: [PATCH] map -> vector optimization with custom waves more comment updates git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/trunk@551 6778bc44-b910-0410-a7a0-be141de4315d --- src/projectM-engine/CustomWave.cpp | 10 +++++----- src/projectM-engine/CustomWave.hpp | 4 +++- src/projectM-engine/Preset.hpp | 4 +--- src/projectM-engine/PresetChooser.hpp | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/projectM-engine/CustomWave.cpp b/src/projectM-engine/CustomWave.cpp index 00ba8f6eb..7078c8d92 100755 --- a/src/projectM-engine/CustomWave.cpp +++ b/src/projectM-engine/CustomWave.cpp @@ -477,8 +477,8 @@ CustomWave::~CustomWave() { - for (std::map::iterator pos = per_point_eqn_tree.begin(); pos != per_point_eqn_tree.end(); ++pos) - delete(pos->second); + for (std::vector::iterator pos = per_point_eqn_tree.begin(); pos != per_point_eqn_tree.end(); ++pos) + delete(*pos); for (std::map::iterator pos = per_frame_eqn_tree.begin(); pos != per_frame_eqn_tree.end(); ++pos) delete(pos->second); @@ -543,7 +543,7 @@ int CustomWave::add_per_point_eqn(char * name, GenExpr * gen_expr) /* Insert the per pixel equation into the preset per pixel database */ - per_point_eqn_tree.insert(std::make_pair(per_point_eqn->index, per_point_eqn)); + per_point_eqn_tree.push_back(per_point_eqn); /* Done */ return PROJECTM_SUCCESS; @@ -591,8 +591,8 @@ void CustomWave::evalPerPointEqns() /* Evaluate per pixel equations */ for (k = 0; k < samples;k++) - for (std::map::iterator pos = per_point_eqn_tree.begin(); pos != per_point_eqn_tree.end();++pos) { - pos->second->evaluate(k); + for (std::vector::iterator pos = per_point_eqn_tree.begin(); pos != per_point_eqn_tree.end();++pos) { + (*pos)->evaluate(k); } } diff --git a/src/projectM-engine/CustomWave.hpp b/src/projectM-engine/CustomWave.hpp index 94536d106..c302b6ed8 100755 --- a/src/projectM-engine/CustomWave.hpp +++ b/src/projectM-engine/CustomWave.hpp @@ -36,6 +36,8 @@ class GenExpr; class PerPointEqn; class Preset; +#include + #include "Common.hpp" #include "Param.hpp" #include "PerFrameEqn.hpp" @@ -116,7 +118,7 @@ public: /* Data structures to hold per frame and per point equations */ std::map init_cond_tree; std::map per_frame_eqn_tree; - std::map per_point_eqn_tree; + std::vector per_point_eqn_tree; std::map per_frame_init_eqn_tree; /* Denotes the index of the last character for each string buffer */ diff --git a/src/projectM-engine/Preset.hpp b/src/projectM-engine/Preset.hpp index 18eb9ffcd..c3cbb3459 100644 --- a/src/projectM-engine/Preset.hpp +++ b/src/projectM-engine/Preset.hpp @@ -59,15 +59,13 @@ public: /// Load a preset by filename with input and output buffers specified. - /// This is the only proper way to allocate a new preset. /// \param absoluteFilePath the absolute file path of a preset to load from the file system /// \param presetName a descriptive name for the preset. Usually just the file name /// \param presetInputs a const reference to read only projectM engine variables /// \param presetOutputs initialized and filled with data parsed from a preset Preset(const std::string & absoluteFilePath, const std::string & presetName, const PresetInputs & presetInputs, PresetOutputs & presetOutputs); - /// Load a preset from a stream with input and output buffers specified. - /// This is the only proper way to allocate a new preset. + /// Load a preset from an input stream with input and output buffers specified. /// \param in an already initialized input stream to read the preset file from /// \param presetName a descriptive name for the preset. Usually just the file name /// \param presetInputs a const reference to read only projectM engine variables diff --git a/src/projectM-engine/PresetChooser.hpp b/src/projectM-engine/PresetChooser.hpp index bf96e1109..0e64f9d4b 100644 --- a/src/projectM-engine/PresetChooser.hpp +++ b/src/projectM-engine/PresetChooser.hpp @@ -42,7 +42,7 @@ public: /// Allocate a new preset given this iterator's associated preset name /// \param presetInputs the preset inputs to associate with the preset upon construction /// \param presetOutputs the preset outputs to associate with the preset upon construction - /// \returns a pointer of the newly allocated preset + /// \returns an autopointer of the newly allocated preset std::auto_ptr allocate(const PresetInputs & presetInputs, PresetOutputs & presetOutputs); /// Set the chooser asocciated with this iterator