Optimizing iteration

prefix ++i is faster than post i++
This commit is contained in:
Bruno
2021-04-18 11:38:03 +02:00
parent 8389010002
commit c6d01c1420
19 changed files with 84 additions and 77 deletions

View File

@@ -19,7 +19,7 @@ MixingGroup::MixingGroup (SourceList sources) : parent_(nullptr), root_(nullptr)
id_ = GlmToolkit::uniqueId();
// fill the vector of sources with the given list
for (auto it = sources.begin(); it != sources.end(); it++){
for (auto it = sources.begin(); it != sources.end(); ++it){
// add only if not linked already
if ((*it)->mixinggroup_ == nullptr) {
(*it)->mixinggroup_ = this;
@@ -43,7 +43,7 @@ MixingGroup::MixingGroup (SourceList sources) : parent_(nullptr), root_(nullptr)
MixingGroup::~MixingGroup ()
{
for (auto it = sources_.begin(); it != sources_.end(); it++)
for (auto it = sources_.begin(); it != sources_.end(); ++it)
(*it)->clearMixingGroup();
if (parent_)
@@ -71,7 +71,7 @@ void MixingGroup::recenter()
{
// compute barycenter (0)
center_pos_ = glm::vec2(0.f, 0.f);
for (auto it = sources_.begin(); it != sources_.end(); it++){
for (auto it = sources_.begin(); it != sources_.end(); ++it){
// compute barycenter (1)
center_pos_ += glm::vec2((*it)->group(View::MIXING)->translation_);
}
@@ -126,7 +126,7 @@ void MixingGroup::update (float)
// compute barycenter (0)
center_pos_ = glm::vec2(0.f, 0.f);
auto it = sources_.begin();
for (; it != sources_.end(); it++){
for (; it != sources_.end(); ++it){
// update point
p[ index_points_[*it] ] = glm::vec2((*it)->group(View::MIXING)->translation_);
@@ -160,7 +160,7 @@ void MixingGroup::update (float)
// compute barycenter (0)
center_pos_ = glm::vec2(0.f, 0.f);
auto it = sources_.begin();
for (; it != sources_.end(); it++){
for (; it != sources_.end(); ++it){
// modify all but the already updated source
if ( *it != updated_source_ && !(*it)->locked() ) {
@@ -196,7 +196,7 @@ void MixingGroup::update (float)
int numactions = 0;
auto it = sources_.begin();
for (; it != sources_.end(); it++){
for (; it != sources_.end(); ++it){
// modify all but the already updated source
if ( *it != updated_source_ && !(*it)->locked() ) {
@@ -256,7 +256,7 @@ void MixingGroup::detach (Source *s)
void MixingGroup::detach (SourceList l)
{
for (auto sit = l.begin(); sit != l.end(); sit++) {
for (auto sit = l.begin(); sit != l.end(); ++sit) {
// find the source
SourceList::iterator its = std::find(sources_.begin(), sources_.end(), *sit);
// ok, its in the list !
@@ -291,7 +291,7 @@ void MixingGroup::attach (Source *s)
void MixingGroup::attach (SourceList l)
{
for (auto sit = l.begin(); sit != l.end(); sit++) {
for (auto sit = l.begin(); sit != l.end(); ++sit) {
if ( (*sit)->mixinggroup_ == nullptr) {
// tell the source
(*sit)->mixinggroup_ = this;
@@ -359,7 +359,7 @@ void MixingGroup::createLineStrip()
// path linking all sources
std::vector<glm::vec2> path;
for (auto it = sources_.begin(); it != sources_.end(); it++){
for (auto it = sources_.begin(); it != sources_.end(); ++it){
index_points_[*it] = path.size();
path.push_back(glm::vec2((*it)->group(View::MIXING)->translation_));
}