From 832fcf965e4b64aa55ae5dbbf6b0d78e0f686dac Mon Sep 17 00:00:00 2001 From: Dan Eble Date: Sat, 11 Jul 2015 15:53:17 -0400 Subject: [PATCH] Issue 4503 (1/4) Clean up Tie::less and Semi_Tie::less --- lily/include/semi-tie.hh | 3 +-- lily/include/tie.hh | 3 +-- lily/semi-tie.cc | 12 +++++++++--- lily/tie.cc | 11 +++++++++-- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/lily/include/semi-tie.hh b/lily/include/semi-tie.hh index 6eb6472e71..8c52dc64d6 100644 --- a/lily/include/semi-tie.hh +++ b/lily/include/semi-tie.hh @@ -29,8 +29,7 @@ struct Semi_tie DECLARE_SCHEME_CALLBACK (calc_direction, (SCM)); DECLARE_SCHEME_CALLBACK (calc_control_points, (SCM)); - static bool less (Grob *const &s1, - Grob *const &s2); + static bool less (Grob *s1, Grob *s2); static int get_column_rank (Item *); static int get_position (Item *); static Item *head (Item *); diff --git a/lily/include/tie.hh b/lily/include/tie.hh index 7b74d159c8..a6b3bf59a7 100644 --- a/lily/include/tie.hh +++ b/lily/include/tie.hh @@ -42,8 +42,7 @@ public: DECLARE_SCHEME_CALLBACK (set_spacing_rods, (SCM)); DECLARE_SCHEME_CALLBACK (calc_direction, (SCM)); DECLARE_SCHEME_CALLBACK (calc_control_points, (SCM)); - static bool less (Grob *const &s1, - Grob *const &s2); + static bool less (Grob *s1, Grob *s2); }; #endif // TIE_HH diff --git a/lily/semi-tie.cc b/lily/semi-tie.cc index 1cc82c3b08..1930087514 100644 --- a/lily/semi-tie.cc +++ b/lily/semi-tie.cc @@ -84,10 +84,16 @@ Semi_tie::get_position (Item *me) } bool -Semi_tie::less (Grob *const &s1, - Grob *const &s2) +Semi_tie::less (Grob *g1, Grob *g2) { - return Tie::get_position_generic (s1) < Tie::get_position_generic (s2); + Item *i1 = dynamic_cast (g1); + Item *i2 = dynamic_cast (g2); + if (i1 && i2) { + return get_position (i1) < get_position (i2); + } + + programming_error ("grob is not a semi-tie"); + return false; } Item * diff --git a/lily/tie.cc b/lily/tie.cc index 47c5a1c9cf..72855687e3 100644 --- a/lily/tie.cc +++ b/lily/tie.cc @@ -42,9 +42,16 @@ #include "semi-tie-column.hh" bool -Tie::less (Grob *const &s1, Grob *const &s2) +Tie::less (Grob *g1, Grob *g2) { - return get_position_generic (s1) < get_position_generic (s2); + Spanner *s1 = dynamic_cast (g1); + Spanner *s2 = dynamic_cast (g2); + if (s1 && s2) { + return get_position (s1) < get_position (s2); + } + + programming_error ("grob is not a tie"); + return false; } void -- 2.39.5