]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/optimal-page-breaking.cc
Fixed example with voltaSpannerDuration. Thanks Neil!
[lilypond.git] / lily / optimal-page-breaking.cc
index f25d75f039ca3a9cebeb3779c8f57fba1bf2f217..34ff7f1b184cb519b418c2b44f53417599a31b4d 100644 (file)
@@ -52,7 +52,7 @@ Optimal_page_breaking::solve ()
   vsize ideal_sys_count = best.system_count ();
   vsize min_sys_count = ideal_sys_count - best.systems_per_page_.back ();
   
-  if (page_count > 1)
+  if (page_count > 1 && best.systems_per_page_[page_count - 2] > 1)
     min_sys_count -= best.systems_per_page_[page_count - 2];
 
   if (page_count == 1)
@@ -92,17 +92,11 @@ Optimal_page_breaking::solve ()
          best_division = bound;
        }
 
-      if (best_for_this_sys_count.systems_per_page_.size () < page_count)
-       {
-         /* if the pages are stretched on average, stop trying to reduce sys_count */
-         Real average_force = 0;
-         for (vsize i = 0; i < best_for_this_sys_count.systems_per_page_.size (); i++)
-           average_force += best_for_this_sys_count.force_[i];
-
-         average_force /= best_for_this_sys_count.page_count (); 
-         if (average_force > 0)
-           break;
-       }
+      /* if the pages are stretched on average, stop trying to reduce sys_count */
+      if (best_for_this_sys_count.page_count () < page_count
+         && best_for_this_sys_count.average_force () > 0)
+       break;
+       
 
       if (isinf (best_for_this_sys_count.demerits_))
        break;