From: Dan Eble Date: Mon, 10 Aug 2015 12:08:04 +0000 (-0400) Subject: Issue 4548: eliminate flip(Direction*) X-Git-Tag: release/2.19.26-1~37 X-Git-Url: https://git.donarmstrong.com/?p=lilypond.git;a=commitdiff_plain;h=4b448c212466623191bc1781da092c7c8ddb6c53 Issue 4548: eliminate flip(Direction*) Use for (DOWN_and_UP (d)) {...} instead. Also replace the few uses of other_dir() with unary minus. --- diff --git a/flower/include/direction.hh b/flower/include/direction.hh index f3b31e3811..de13ef4ca8 100644 --- a/flower/include/direction.hh +++ b/flower/include/direction.hh @@ -49,26 +49,9 @@ enum Direction }; inline Direction -other_dir (Direction const d) +operator - (Direction d) { - return (Direction) (-d); -} - -inline Direction -operator - (Direction const d) -{ - return other_dir (d); -} - -// to be deleted soon (after coping with issues 2491 and 2493 -inline Direction -flip (Direction *i) -{ - if (*i == (Direction)1) - *i = (Direction) - 1; - else if (*i == (Direction) - 1) - *i = (Direction)1; - return *i; + return Direction (- static_cast (d)); // cast avoids recursion } #define UP_and_DOWN(d) \ @@ -92,6 +75,4 @@ template T minmax (Direction d, T a, T b) return min (a, b); } -// String direction_string (Direction, Axis); - #endif // DIRECTION_HH diff --git a/lily/beaming-pattern.cc b/lily/beaming-pattern.cc index cb8c91dbec..f205df8d78 100644 --- a/lily/beaming-pattern.cc +++ b/lily/beaming-pattern.cc @@ -165,7 +165,7 @@ Beaming_pattern::beamify (Beaming_options const &options) for (int i = 0; i < 2; i++) for (vsize i = 1; i < infos_.size () - 1; i++) { - Direction non_flag_dir = other_dir (flag_directions[i]); + Direction non_flag_dir = -flag_directions[i]; if (non_flag_dir) { int importance = infos_[i + 1].rhythmic_importance_; diff --git a/lily/line-spanner.cc b/lily/line-spanner.cc index 925e578e35..84c43ccf81 100644 --- a/lily/line-spanner.cc +++ b/lily/line-spanner.cc @@ -168,7 +168,7 @@ Line_spanner::calc_bound_info (SCM smob, Direction dir) VerticalAxisGroup of a staff) that extends over the break. */ Spanner *next_bound_parent_on_this_line - = next_bound_parent->broken_neighbor (other_dir (dir)); + = next_bound_parent->broken_neighbor (-dir); if (next_bound_parent_on_this_line) { diff --git a/lily/stencil-integral.cc b/lily/stencil-integral.cc index f11858baa5..747217c847 100644 --- a/lily/stencil-integral.cc +++ b/lily/stencil-integral.cc @@ -190,8 +190,7 @@ make_draw_line_boxes (vector &boxes, vector > &buildings Offset left (x0, y0); Offset right (x1, y1); Offset dir = (right - left).direction (); - Direction d = DOWN; - do + for (DOWN_and_UP (d)) { Offset outward = d * get_normal ((thick / 2) * dir); Offset inter_l = left + outward; @@ -231,7 +230,6 @@ make_draw_line_boxes (vector &boxes, vector > &buildings } } } - while (flip (&d) != DOWN); if (thick > 0.0) { @@ -280,9 +278,8 @@ make_partial_ellipse_boxes (vector &boxes, Offset ep (cos (end) * x_rad, sin (end) * y_rad); ////////////////////// Drul_array > points; - Direction d = DOWN; int quantization = max (1, (int) (((x_rad * trans.xx) + (y_rad * trans.yy)) * M_PI / QUANTIZATION_UNIT)); - do + for (DOWN_and_UP (d)) { for (vsize i = 0; i < 1 + (vsize) quantization; i++) { @@ -293,17 +290,15 @@ make_partial_ellipse_boxes (vector &boxes, points[d].push_back (inter); } } - while (flip (&d) != DOWN); for (vsize i = 0; i < points[DOWN].size () - 1; i++) { Box b; - do + for (DOWN_and_UP (d)) { b.add_point (points[d][i]); b.add_point (points[d][i + 1]); } - while (flip (&d) != DOWN); boxes.push_back (b); } @@ -421,12 +416,11 @@ make_draw_bezier_boxes (vector &boxes, pango_matrix_transform_point (&trans, &temp3[X_AXIS], &temp3[Y_AXIS]); ////////////////////// Drul_array > points; - Direction d = DOWN; int quantization = int (((temp1 - temp0).length () + (temp2 - temp1).length () + (temp3 - temp2).length ()) / QUANTIZATION_UNIT); - do + for (DOWN_and_UP (d)) { Offset first = curve.control_[0] + d * get_normal ((th / 2) * curve.dir_at_point (0.0)); @@ -445,17 +439,15 @@ make_draw_bezier_boxes (vector &boxes, pango_matrix_transform_point (&trans, &last[X_AXIS], &last[Y_AXIS]); points[d].push_back (last); } - while (flip (&d) != DOWN); for (vsize i = 0; i < points[DOWN].size () - 1; i++) { Box b; - do + for (DOWN_and_UP (d)) { b.add_point (points[d][i]); b.add_point (points[d][i + 1]); } - while (flip (&d) != DOWN); boxes.push_back (b); }