]> git.donarmstrong.com Git - lilypond.git/commitdiff
Also cache fixed_spacing.
authorJoe Neeman <joeneeman@gmail.com>
Fri, 14 Jan 2011 12:33:14 +0000 (13:33 +0100)
committerJoe Neeman <joeneeman@gmail.com>
Sun, 13 Feb 2011 22:37:20 +0000 (09:37 +1100)
Fixes the performance regression introduced in 5266aa.

lily/page-layout-problem.cc

index 54624304d540f60b85367e2bdf54be296b415ef3..c0af4dae1e0dd54b6cebdfb4e03edd3c285eef87 100644 (file)
@@ -658,6 +658,19 @@ Page_layout_problem::read_spacing_spec (SCM spec, Real* dest, SCM sym)
 Real
 Page_layout_problem::get_fixed_spacing (Grob *before, Grob *after, int spaceable_index, bool pure, int start, int end)
 {
+  Spanner *after_sp = dynamic_cast<Spanner*> (after);
+  SCM cache_symbol = (is_spaceable (before) && is_spaceable (after))
+    ? ly_symbol2scm ("spaceable-fixed-spacing")
+    : ly_symbol2scm ("loose-fixed-spacing");
+  if (pure)
+    {
+      // The result of this function doesn't depend on "end," so we can reduce the
+      // size of the cache by ignoring it.
+      SCM cached = after_sp->get_cached_pure_property (cache_symbol, start, 0);
+      if (scm_is_number (cached))
+       return robust_scm2double (cached, 0.0);
+    }
+
   SCM spec = Page_layout_problem::get_spacing_spec (before, after, pure, start, end);
   Real ret = -infinity_f;
   Real stretchability = 0;
@@ -681,6 +694,11 @@ Page_layout_problem::get_fixed_spacing (Grob *before, Grob *after, int spaceable
            ret = max (ret, scm_to_double (forced));
        }
     }
+
+  // Cache the result.  As above, we ignore "end."
+  if (pure)
+    after_sp->cache_pure_property (cache_symbol, start, 0, scm_from_double (ret));
+    
   return ret;
 }