lilypond-devel
[Top][All Lists]
Advanced

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

Re: make_draw_bezier_boxes: save work if thickness == 0.0 (issue 5517300


From: hanwenn
Subject: Re: make_draw_bezier_boxes: save work if thickness == 0.0 (issue 551730043 by address@hidden)
Date: Fri, 24 Apr 2020 11:44:05 -0700

Reviewers: Dan Eble,

Message:
The percentages between different have looked fairly repeatable, but as
a less invasive measure is to just tweak the final 'if'

Description:
make_draw_bezier_boxes: save work if thickness == 0.0

This drop make_draw_bezier_boxes from 0.73% to 0.44% in the profile for
MSDM

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

Affected files (+24, -5 lines):
  M lily/stencil-integral.cc


Index: lily/stencil-integral.cc
diff --git a/lily/stencil-integral.cc b/lily/stencil-integral.cc
index 
189cdcdc881ec0c1c417a4a783b4675446ec4207..e43bbee6cd14756bcf0b6e4a575c68b3abd4a136
 100644
--- a/lily/stencil-integral.cc
+++ b/lily/stencil-integral.cc
@@ -480,12 +480,20 @@ make_draw_bezier_boxes (vector<Box> &boxes,
                            + (temp3 - temp2).length ())
                           / QUANTIZATION_UNIT);
 
-  Offset d0 = curve.dir_at_point (0.0);
-  Offset d1 = curve.dir_at_point (1.0);
+  Offset d0;
+  Offset d1;
+
+  Offset normal;
+  if (th > 0)
+    {
+      d0 = curve.dir_at_point (0.0);
+      normal = get_normal ((th / 2) * d0);
+    }
 
-  Offset normal = get_normal ((th / 2) * d0);
   for (DOWN_and_UP (d))
     {
+      if (th == 0.0 && d == UP)
+        break;
       points[d].push_back (
         scm_transform (trans, curve.control_[0] + d * normal));
     }
@@ -497,14 +505,23 @@ make_draw_bezier_boxes (vector<Box> &boxes,
 
       for (DOWN_and_UP (d))
         {
+          if (th == 0.0 && d == UP)
+            break;
           points[d].push_back (
             scm_transform (trans, curve.curve_point (pt) + d * norm));
         }
     }
 
-  normal = get_normal ((th / 2) * d1);
+  if (th > 0)
+    {
+      d1 = curve.dir_at_point (1.0);
+      normal = get_normal ((th / 2) * d1);
+    }
+
   for (DOWN_and_UP (d))
     {
+      if (th == 0.0 && d == UP)
+        break;
       points[d].push_back (
         scm_transform (trans, curve.control_[3] + d * normal));
     }
@@ -514,13 +531,15 @@ make_draw_bezier_boxes (vector<Box> &boxes,
       Box b;
       for (DOWN_and_UP (d))
         {
+          if (th == 0.0 && d == UP)
+            break;
           b.add_point (points[d][i]);
           b.add_point (points[d][i + 1]);
         }
       boxes.push_back (b);
     }
 
-  if (th >= 0)
+  if (th > 0)
     {
       // beg line cap
       create_path_cap (boxes, buildings, trans, curve.control_[0], th / 2, 
-d0);





reply via email to

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