[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Part_combine_iterator: simplify context substitution (issue 238070043 by
From: |
nine . fierce . ballads |
Subject: |
Part_combine_iterator: simplify context substitution (issue 238070043 by address@hidden) |
Date: |
Sat, 09 May 2015 01:42:16 +0000 |
Reviewers: ,
Description:
Part_combine_iterator: simplify context substitution. There are no
regression test differences, but I'm concerned that there might be a
reason for the way this was written that the tests do not exercise.
Music_iterator::substitute_outlet: do nothing if the new outlet is
identical to the old (a sanity test)
Please review this at https://codereview.appspot.com/238070043/
Affected files (+10, -13 lines):
M lily/music-iterator.cc
M lily/part-combine-iterator.cc
Index: lily/music-iterator.cc
diff --git a/lily/music-iterator.cc b/lily/music-iterator.cc
index
8eb238c295bc6d95e47187e6995358e9ac4ab01d..dabcccfb25aaeb4b56160e550155df72ab18338c
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
Index: lily/part-combine-iterator.cc
diff --git a/lily/part-combine-iterator.cc b/lily/part-combine-iterator.cc
index
4d1baec7568b3d24939dac9c7bdac59b5467ad00..880129d8e1d78d42b8d317619bf8ddb385530384
100644
--- a/lily/part-combine-iterator.cc
+++ b/lily/part-combine-iterator.cc
@@ -198,16 +198,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++)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Part_combine_iterator: simplify context substitution (issue 238070043 by address@hidden),
nine . fierce . ballads <=