]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-1.3.15
authorfred <fred>
Tue, 26 Mar 2002 22:44:33 +0000 (22:44 +0000)
committerfred <fred>
Tue, 26 Mar 2002 22:44:33 +0000 (22:44 +0000)
lily/score-element.cc

index b7d6ce8a794fd64d3dea31bf6184206b94aa833c..6d3be5981c996fcc980d5185b1cc793823e18abd 100644 (file)
@@ -198,7 +198,7 @@ Score_element::lookup_l () const
     {
       Score_element * urg = (Score_element*)this;
       SCM sz = urg->remove_elt_property ("fontsize");
-      int i = (sz != SCM_UNDEFINED)
+      int i = (gh_number_p (sz))
        ? gh_scm2int  (sz)
        : 0;
 
@@ -367,6 +367,9 @@ Score_element::add_dependency (Score_element*e)
 SCM
 Score_element::handle_broken_smobs (SCM s, SCM criterion)
 {
+ again:
+
+  
   Score_element *sc = unsmob_element ( s);
   if (sc)
     {
@@ -402,16 +405,25 @@ Score_element::handle_broken_smobs (SCM s, SCM criterion)
       /*
        UGH! breaks on circular lists.
       */
-      gh_set_car_x (s, handle_broken_smobs (gh_car (s), criterion));
-      gh_set_cdr_x (s, handle_broken_smobs (gh_cdr (s), criterion));
-
-      SCM c = gh_cdr(s);
-
-      // gh_list_p () is linear, this is O(1)  
-      bool list = gh_pair_p (c) || c == SCM_EOL;
+      SCM car = handle_broken_smobs (gh_car (s), criterion);
+      SCM cdr = gh_cdr (s);
       
-      if (gh_car (s) == SCM_UNDEFINED && list)
-       return c;
+      if (car == SCM_UNDEFINED
+         && (gh_pair_p (cdr) || cdr == SCM_EOL))
+       {
+         /*
+           This is tail-recursion, ie. 
+           
+           return handle_broken_smobs (cdr, criterion);
+
+           We don't want to rely on the compiler to do this.  */
+         s =  cdr;     
+         goto again;
+       }
+
+      gh_set_car_x (s, car);
+      gh_set_cdr_x (s, handle_broken_smobs (cdr, criterion));
+      return s;
     }
   return s;
 }