]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/music-iterator.cc
* scm/music-functions.scm (descend-to-context): new
[lilypond.git] / lily / music-iterator.cc
index 9fc288866e809fcee74294d2207d9c13bb71476e..43e28e3ebde725b92cdeefe065d1410acc2aca41 100644 (file)
@@ -237,6 +237,18 @@ Music_iterator::run_always ()const
   return false;
 }
 
+
+bool
+is_child_context (Context *me, Context *child)
+{
+  while (child && child != me)
+    {
+      child = child->daddy_context_;
+    }
+  
+  return child == me;
+}
+
 /*
   move to context of child iterator if it is deeper down in the
   hierarchy.
@@ -245,13 +257,6 @@ void
 Music_iterator::descend_to_child (Context * child_report)
 {
   Context * me_report = get_outlet ();
-
-  Context * c = child_report;
-  while (c && c != me_report)
-    {
-      c = c->daddy_context_;
-    }
-  
-  if (c == me_report)
+  if (is_child_context (me_report, child_report))
     set_translator (child_report);
 }