From 52ea0de9968eb2efa4e47388e5f90dfc6308422c Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer Date: Tue, 17 Nov 2009 17:45:23 +0100 Subject: [PATCH] tie_performer: Use iterator rather than accessing by index --- lily/tie-performer.cc | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lily/tie-performer.cc b/lily/tie-performer.cc index fd3c0bbb65..0d60c758cb 100644 --- a/lily/tie-performer.cc +++ b/lily/tie-performer.cc @@ -62,14 +62,18 @@ Tie_performer::acknowledge_audio_element (Audio_element_info inf) else now_heads_.push_back (inf); - for (vsize i = heads_to_tie_.size (); i--;) - { - Stream_event *right_mus = inf.event_; - - Audio_note *th = dynamic_cast (heads_to_tie_[i].elem_); - Stream_event *left_mus = heads_to_tie_[i].event_; - - if (right_mus && left_mus + // Find a previous note that ties to the current note. If it exists, + // remove it from the heads_to_tie vector and create the tie + vector::iterator it; + bool found = false; + Stream_event *right_mus = inf.event_; + for ( it = heads_to_tie_.begin() ; (!found) && (it < heads_to_tie_.end()); it++ ) + { + Audio_element_info et = *it; + Audio_note *th = dynamic_cast (et.elem_); + Stream_event *left_mus = et.event_; + + if (th && right_mus && left_mus && ly_is_equal (right_mus->get_property ("pitch"), left_mus->get_property ("pitch"))) { @@ -90,7 +94,6 @@ Tie_performer::start_translation_timestep () void Tie_performer::stop_translation_timestep () { - // Clear tie information if we created ties. If we didn't create ties, // We might have dangling open ties like c~ d. Close them, unless we have // tieWaitForNote set... if (ties_created_ || !to_boolean (get_property ("tieWaitForNote"))) -- 2.39.5