]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 4379: Part_combine_iterator: simplify context substitution
authorDan Eble <nine.fierce.ballads@gmail.com>
Sat, 9 May 2015 01:35:04 +0000 (21:35 -0400)
committerDan Eble <nine.fierce.ballads@gmail.com>
Sat, 16 May 2015 10:37:14 +0000 (06:37 -0400)
Music_iterator::substitute_outlet: do nothing if the new outlet is
identical to the old (a sanity test)

lily/music-iterator.cc
lily/part-combine-iterator.cc

index 8eb238c295bc6d95e47187e6995358e9ac4ab01d..dabcccfb25aaeb4b56160e550155df72ab18338c 100644 (file)
@@ -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
index a96306d0847a3644c8d9c715d45cb6c129605522..c5437a63e56424058967cdbf30bdc35a2f6ce535 100644 (file)
@@ -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++)
     {