]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/paper-column.cc
Issue 5057/2: Use Protected_scm::is_bound () with Scheme engravers
[lilypond.git] / lily / paper-column.cc
index 692a28f9d9333f7472113e4f5b7c73fca2b82fc8..5462027928693c15aa9a85d00ccca134b8945173 100644 (file)
@@ -39,9 +39,6 @@
 #include "text-interface.hh"
 #include "warn.hh"
 
-using std::string;
-using std::vector;
-
 Grob *
 Paper_column::clone () const
 {
@@ -179,7 +176,7 @@ Paper_column::minimum_distance (Grob *left, Grob *right)
 
   skys[RIGHT].merge (Separation_item::conditional_skyline (right, left));
 
-  return std::max (0.0, skys[LEFT].distance (skys[RIGHT]));
+  return max (0.0, skys[LEFT].distance (skys[RIGHT]));
 }
 
 Interval
@@ -212,7 +209,8 @@ Paper_column::break_align_width (Grob *me, SCM align_syms)
           extract_grob_set (me, "elements", elts);
           for (vsize i = 0; i < elts.size (); i++)
             {
-              if (elts[i]->get_property ("break-align-symbol") == align_sym
+              if (scm_is_eq (align_sym, elts[i]->get_property ("break-align-symbol"))
+                  // TODO SCM: there must be a simpler way to put this.
                   && !elts[i]->extent (elts[i], X_AXIS).is_empty ())
                 {
                   align = elts[i];
@@ -393,6 +391,11 @@ Paper_column::print (SCM p)
   return t.smobbed_copy ();
 }
 
+static bool grob_is_live (const Grob *g)
+{
+  return g && g->is_live ();
+}
+
 /*
   This is all too hairy. We use bounded-by-me to make sure that some
   columns are kept "alive". Unfortunately, when spanners are suicided,
@@ -407,21 +410,8 @@ Paper_column::before_line_breaking (SCM grob)
 {
   Grob *me = unsmob<Grob> (grob);
 
-  SCM bbm = me->get_object ("bounded-by-me");
-  Grob_array *ga = unsmob<Grob_array> (bbm);
-  if (!ga)
-    return SCM_UNSPECIFIED;
-
-  vector<Grob *> &array (ga->array_reference ());
-
-  for (vsize i = array.size (); i--;)
-    {
-      Grob *g = array[i];
-
-      if (!g || !g->is_live ())
-        /* UGH . potentially quadratic. */
-        array.erase (array.begin () + i);
-    }
+  if (Grob_array *ga = unsmob<Grob_array> (me->get_object ("bounded-by-me")))
+    ga->filter (grob_is_live);
 
   return SCM_UNSPECIFIED;
 }