]> git.donarmstrong.com Git - lilypond.git/commitdiff
grob-property: if callback is independent of layout, call just once
authorKeith OHara <k-ohara5a5a@oco.net>
Sat, 14 Dec 2013 05:46:49 +0000 (21:46 -0800)
committerKeith OHara <k-ohara5a5a@oco.net>
Wed, 25 Dec 2013 18:55:08 +0000 (10:55 -0800)
lily/grob-property.cc
lily/include/unpure-pure-container.hh
lily/unpure-pure-container.cc

index f9773e5ec5a4878b12f66f1535970a5696e6ff8a..32ff49124dff37919c6e21b5b8778874338c188b 100644 (file)
@@ -197,8 +197,17 @@ SCM
 Grob::internal_get_pure_property (SCM sym, int start, int end) const
 {
   SCM val = internal_get_property_data (sym);
-  if (ly_is_procedure (val) || is_unpure_pure_container (val))
+  if (ly_is_procedure (val))
     return call_pure_function (val, scm_list_1 (self_scm ()), start, end);
+
+  if (is_unpure_pure_container (val)) {
+    // Do cache, if the function ignores 'start' and 'end'
+    if (is_unchanging_unpure_pure_container (val))
+      return internal_get_property (sym);
+    else
+      return call_pure_function (val, scm_list_1 (self_scm ()), start, end);
+  }
+
   if (is_simple_closure (val))
     return evaluate_with_simple_closure (self_scm (),
                                          simple_closure_expression (val),
index ccf0971844aa7721662321e96a883b2e676d69e3..e4347b4d0a293045ad18301517a1459ea49b7c77 100644 (file)
@@ -23,6 +23,7 @@
 #include "lily-guile.hh"
 
 bool is_unpure_pure_container (SCM s);
+bool is_unchanging_unpure_pure_container (SCM s);
 SCM unpure_pure_container_unpure_part (SCM smob);
 SCM unpure_pure_container_pure_part (SCM smob);
 SCM ly_make_unpure_pure_container (SCM, SCM);
index 9b2f871769356ea1de2f47900d8a5a6fb5ffb037..b8d1e2d4a5a84d5458c30af1b1a4fcd64754946d 100644 (file)
@@ -32,6 +32,17 @@ is_unpure_pure_container (SCM s)
   return (SCM_NIMP (s) && SCM_CELL_TYPE (s) == unpure_pure_container_tag);
 }
 
+bool
+is_unchanging_unpure_pure_container (SCM s)
+// A container that has the same callback for both 'pure' and 'unpure' lookups
+// and which ignores the 'start' and 'end' columnns.
+// Such a callback will give the same answer for tentative or final layouts.
+{
+  LY_ASSERT_TYPE (is_unpure_pure_container, s, 1);
+  SCM pure_part = SCM_SMOB_OBJECT_2 (s);
+  return (SCM_UNBNDP (pure_part));
+}
+
 SCM
 unpure_pure_container_unpure_part (SCM smob)
 {