]> git.donarmstrong.com Git - lilypond.git/commitdiff
Always cap shortest_playing_len by measure length.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 20 Dec 2006 00:03:16 +0000 (01:03 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 20 Dec 2006 00:03:16 +0000 (01:03 +0100)
Make get_measure_length() more efficient by using
Paper_column::get_rank as array index.

lily/spacing-basic.cc
lily/system.cc

index 2e81fdf416237d2569dcedd1f94960cb91e02bba..4387c788be52fff6718648e0f7a2e09caae045fe 100644 (file)
@@ -86,14 +86,7 @@ get_measure_length (Grob *column)
 
   extract_grob_set (sys, "columns", cols);
 
-  vsize col_idx = binary_search (cols, column,
-                                Paper_column::less_than);
-
-  if (col_idx == VPOS)
-    {
-      programming_error ( __FUNCTION__ + string (": Unknown column"));
-      return 0;
-    }
+  vsize col_idx = Paper_column::get_rank (column);
   
   do
     {
@@ -130,25 +123,26 @@ Spacing_spanner::note_spacing (Grob *me, Grob *lc, Grob *rc,
   Moment rwhen = Paper_column::when_mom (rc);
 
   Moment delta_t = rwhen - lwhen;
-  if (!Paper_column::is_musical (rc))
+
+  /*
+    when toying with mmrests, it is possible to have musical
+    column on the left and non-musical on the right, spanning
+    several measures.
+
+    TODO: efficiency: measure length can be cached, or stored as
+    property in paper-column.
+  */
+
+  Moment *dt = get_measure_length (lc);
+  if (dt)
     {
+      delta_t = min (delta_t, *dt);
+
       /*
-       when toying with mmrests, it is possible to have musical
-       column on the left and non-musical on the right, spanning
-       several measures.
+       The following is an extra safety measure, such that
+       the length of a mmrest event doesn't cause havoc.
       */
-
-      Moment *dt = get_measure_length (lc);
-      if (dt)
-       {
-         delta_t = min (delta_t, *dt);
-
-         /*
-           The following is an extra safety measure, such that
-           the length of a mmrest event doesn't cause havoc.
-         */
-         shortest_playing_len = min (shortest_playing_len, *dt);
-       }
+      shortest_playing_len = min (shortest_playing_len, *dt);
     }
 
   Real dist = 0.0;
index 90eb463c44932ac307902bd3e8a7e5e210b7984f..3ca397976b06c890094fdc2673deefc9fbc50833 100644 (file)
@@ -245,10 +245,7 @@ System::add_column (Paper_column *p)
       ga = unsmob_grob_array (scm_ga);
     }
 
-  p->rank_
-    = ga->size ()
-    ? Paper_column::get_rank (ga->array ().back ()) + 1
-    : 0;
+  p->rank_ = ga->size ();
 
   ga->add (p);
   Axis_group_interface::add_element (this, p);