lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Issue 4548: eliminate flip(Direction*) (issue 260060043 by address@hidde


From: nine . fierce . ballads
Subject: Issue 4548: eliminate flip(Direction*) (issue 260060043 by address@hidden)
Date: Mon, 10 Aug 2015 12:28:32 +0000

Reviewers: ,

Description:
Issue 4548: eliminate flip(Direction*)

Use for (DOWN_and_UP (d)) {...} instead.
Also replace the few uses of other_dir() with unary minus.

Please review this at https://codereview.appspot.com/260060043/

Affected files (+9, -36 lines):
  M flower/include/direction.hh
  M lily/beaming-pattern.cc
  M lily/line-spanner.cc
  M lily/stencil-integral.cc


Index: flower/include/direction.hh
diff --git a/flower/include/direction.hh b/flower/include/direction.hh
index f3b31e3811a7c5245c294cbd72322b9dc3cd184d..de13ef4ca8a6341ea7ce843f22fdc76e00f982bb 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<int> (d)); // cast avoids recursion
 }

 #define UP_and_DOWN(d) \
@@ -92,6 +75,4 @@ template<class T> T minmax (Direction d, T a, T b)
     return min (a, b);
 }

-// String direction_string (Direction, Axis);
-
 #endif // DIRECTION_HH
Index: lily/beaming-pattern.cc
diff --git a/lily/beaming-pattern.cc b/lily/beaming-pattern.cc
index cb8c91dbece9de761ba7a5d1421e4f5e8c12987c..f205df8d78a14014c0d23547e7afaf5601f6166c 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_;
Index: lily/line-spanner.cc
diff --git a/lily/line-spanner.cc b/lily/line-spanner.cc
index be20f25d98fb0a824030cb48ecd4faa77bfa3974..79778fdb52abbd00a4ad84c609d5fa775b9dfac6 100644
--- a/lily/line-spanner.cc
+++ b/lily/line-spanner.cc
@@ -169,7 +169,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)
                 {
Index: lily/stencil-integral.cc
diff --git a/lily/stencil-integral.cc b/lily/stencil-integral.cc
index f11858baa594f4db917ce60713ef6ed502fab4ce..747217c847024b993b307555edcca46c85b025d1 100644
--- a/lily/stencil-integral.cc
+++ b/lily/stencil-integral.cc
@@ -190,8 +190,7 @@ make_draw_line_boxes (vector<Box> &boxes, vector<Drul_array<Offset> > &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<Box> &boxes, vector<Drul_array<Offset> > &buildings
             }
         }
     }
-  while (flip (&d) != DOWN);

   if (thick > 0.0)
     {
@@ -280,9 +278,8 @@ make_partial_ellipse_boxes (vector<Box> &boxes,
   Offset ep (cos (end) * x_rad, sin (end) * y_rad);
   //////////////////////
   Drul_array<vector<Offset> > 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<Box> &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<Box> &boxes,
   pango_matrix_transform_point (&trans, &temp3[X_AXIS], &temp3[Y_AXIS]);
   //////////////////////
   Drul_array<vector<Offset> > 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<Box> &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);
     }






reply via email to

[Prev in Thread] Current Thread [Next in Thread]