From: Dan Eble Date: Sat, 9 May 2015 01:35:04 +0000 (-0400) Subject: Issue 4379: Part_combine_iterator: simplify context substitution X-Git-Tag: release/2.19.21-1~35 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=778c2d11b2c5fe2ec8ef3f531e92b331214de4e9;p=lilypond.git Issue 4379: Part_combine_iterator: simplify context substitution Music_iterator::substitute_outlet: do nothing if the new outlet is identical to the old (a sanity test) --- diff --git a/lily/music-iterator.cc b/lily/music-iterator.cc index 8eb238c295..dabcccfb25 100644 --- a/lily/music-iterator.cc +++ b/lily/music-iterator.cc @@ -132,9 +132,12 @@ Music_iterator::init_context (Music *m, Context *report) void Music_iterator::substitute_outlet (Context *f, Context *t) { - if (get_outlet () == f) - set_context (t); - derived_substitute (f, t); + if (f != t) + { + if (get_outlet () == f) + set_context (t); + derived_substitute (f, t); + } } void diff --git a/lily/part-combine-iterator.cc b/lily/part-combine-iterator.cc index a96306d084..c5437a63e5 100644 --- a/lily/part-combine-iterator.cc +++ b/lily/part-combine-iterator.cc @@ -186,16 +186,10 @@ void Part_combine_iterator::substitute_both (Outlet_type to1, Outlet_type to2) { - Outlet_type tos[] = {to1, to2}; - - Music_iterator *mis[] = {first_iter_, second_iter_}; - - for (int i = 0; i < 2; i++) - { - for (int j = 0; j < NUM_OUTLETS; j++) - if (j != tos[i]) - mis[i]->substitute_outlet (handles_[j].get_context (), handles_[tos[i]].get_context ()); - } + first_iter_->substitute_outlet (first_iter_->get_outlet (), + handles_[to1].get_context ()); + second_iter_->substitute_outlet (second_iter_->get_outlet (), + handles_[to2].get_context ()); for (int j = 0; j < NUM_OUTLETS; j++) {