X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fbreak-substitution.cc;h=d198753d673b88bda66d51e8029259f9d4307681;hb=97a0169312a260933246ab224e4f8b0969871dd5;hp=f26e9510bc9dd565c7288ea83c182bee8a49a895;hpb=809acd76be2af232cb4cbc43f86dad820bf97ae0;p=lilypond.git diff --git a/lily/break-substitution.cc b/lily/break-substitution.cc index f26e9510bc..d198753d67 100644 --- a/lily/break-substitution.cc +++ b/lily/break-substitution.cc @@ -51,7 +51,7 @@ substitute_grob (Grob *sc) else { System *line - = derived_unsmob (break_criterion); + = unsmob (break_criterion); if (sc->get_system () != line) sc = sc->find_broken_piece (line); @@ -101,9 +101,9 @@ do_break_substitution (SCM src) { again: - if (Grob::is_smob (src)) + if (unsmob (src)) { - Grob *new_ptr = substitute_grob (Grob::unsmob (src)); + Grob *new_ptr = substitute_grob (unsmob (src)); return new_ptr ? new_ptr->self_scm () : SCM_UNDEFINED; } else if (scm_is_vector (src)) @@ -147,34 +147,6 @@ again: return src; } -/* - Perform substitution on GROB_LIST using a constant amount of stack. -*/ -vector temporary_substition_array; -void -substitute_grob_array (Grob_array *grob_arr, Grob_array *new_arr) -{ - vector &old_grobs (grob_arr->array_reference ()); - vector *new_grobs (new_arr == grob_arr - ? & temporary_substition_array - : &new_arr->array_reference ()); - - new_grobs->resize (old_grobs.size ()); - Grob **array = (Grob **) new_grobs->data (); - Grob **ptr = array; - for (vsize i = 0; i < old_grobs.size (); i++) - { - Grob *orig = old_grobs[i]; - Grob *new_grob = substitute_grob (orig); - if (new_grob) - *ptr++ = new_grob; - } - - new_grobs->resize (ptr - array); - if (new_arr == grob_arr) - new_arr->set_array (*new_grobs); -} - /* We don't do @@ -408,13 +380,13 @@ Spanner::fast_substitute_grob_array (SCM sym, set_break_subsititution (l ? l->self_scm () : SCM_UNDEFINED); SCM newval = sc->internal_get_object (sym); - if (!Grob_array::is_smob (newval)) + if (!unsmob (newval)) { newval = Grob_array::make_array (); sc->set_object (sym, newval); } - Grob_array *new_array = Grob_array::unsmob (newval); + Grob_array *new_array = unsmob (newval); for (int k = 0; k < 2; k++) for (int j = (*arrs[k])[i][LEFT]; j <= (*arrs[k])[i][RIGHT]; j++) { @@ -461,7 +433,7 @@ substitute_object_alist (SCM alist, SCM dest) SCM sym = scm_caar (s); SCM val = scm_cdar (s); - if (Grob_array *orig = Grob_array::unsmob (val)) + if (Grob_array *orig = unsmob (val)) { SCM handle = scm_assq (sym, dest); SCM newval @@ -469,9 +441,9 @@ substitute_object_alist (SCM alist, SCM dest) ? scm_cdr (handle) : Grob_array::make_array (); - Grob_array *new_arr = Grob_array::unsmob (newval); - - substitute_grob_array (orig, new_arr); + Grob_array *new_arr = unsmob (newval); + // TODO: What if new_arr is null? + new_arr->filter_map_assign (*orig, substitute_grob); val = newval; } else @@ -497,7 +469,7 @@ Spanner::substitute_one_mutable_property (SCM sym, Spanner *s = this; bool fast_done = false; - Grob_array *grob_array = Grob_array::unsmob (val); + Grob_array *grob_array = unsmob (val); if (grob_array) fast_done = s->fast_substitute_grob_array (sym, grob_array); @@ -511,12 +483,13 @@ Spanner::substitute_one_mutable_property (SCM sym, if (grob_array) { SCM newval = sc->internal_get_object (sym); - if (!Grob_array::is_smob (newval)) + if (!unsmob (newval)) { newval = Grob_array::make_array (); sc->set_object (sym, newval); } - substitute_grob_array (grob_array, Grob_array::unsmob (newval)); + Grob_array *new_arr = unsmob (newval); + new_arr->filter_map_assign (*grob_array, substitute_grob); } else {