[cairo] perf: long dashed lines

Behdad Esfahbod behdad at behdad.org
Mon Feb 4 20:51:29 PST 2008


On Mon, 2008-02-04 at 18:00 -0800, Vladimir Vukicevic wrote:
> 
> +    cairo_matrix_transform_distance (ctm_inverse, &dx0, &dy0);
> +
> +    if (dx0 == 0.0 && dy0 == 0.0) {
> +       if (mag_out)
> +           *mag_out = 0.0;
> +       return FALSE;
> +    }
> +
> +    mag = sqrt (dx0 * dx0 + dy0 * dy0);
> +

I was thinking about:


+    if (dx0 == 0.0 && dy0 == 0.0) {
+       if (mag_out)
+           *mag_out = 0.0;
+       return FALSE;
+    }
+
+    cairo_matrix_transform_distance (ctm_inverse, &dx0, &dy0);
+
+    if (dx0 == 0.0)
+        mag = dy0;
+    else if (dy0 == 0.0)
+        mag = dx0;
+    else
+        mag = sqrt (dx0 * dx0 + dy0 * dy0);

If I was being lazy, I could write that last part this way:

+    if (dx0 == 0.0 || dy0 == 0.0)
+        mag = dx0 + dy0;
+    else
+        mag = sqrt (dx0 * dx0 + dy0 * dy0);


Anyway, looks good.  Please commit.

-- 
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759



More information about the cairo mailing list