From 778c2d11b2c5fe2ec8ef3f531e92b331214de4e9 Mon Sep 17 00:00:00 2001 From: Dan Eble Date: Fri, 8 May 2015 21:35:04 -0400 Subject: [PATCH] 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) --- lily/music-iterator.cc | 9 ++++++--- lily/part-combine-iterator.cc | 14 ++++---------- 2 files changed, 10 insertions(+), 13 deletions(-) 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++) { -- 2.39.5