From 85b688a3f6271427befca699de3a7a15162fc59e Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Mon, 3 Aug 2009 22:27:22 +0100 Subject: [matrix] Use hypot() Use hypot() instead of open-coding sqrt(x*x + y*y). In theory, the compiler could emit highly efficient code. In practice it's slower, but more likely to be more accurate -- but the difference over a bare sqrt() is likely not to be perceptible. --- src/cairo-matrix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/cairo-matrix.c') diff --git a/src/cairo-matrix.c b/src/cairo-matrix.c index b9e7290a..6c83388e 100644 --- a/src/cairo-matrix.c +++ b/src/cairo-matrix.c @@ -624,7 +624,7 @@ _cairo_matrix_compute_basis_scale_factors (const cairo_matrix_t *matrix, double major, minor; cairo_matrix_transform_distance (matrix, &x, &y); - major = sqrt(x*x + y*y); + major = hypot (x, y); /* * ignore mirroring */ @@ -856,7 +856,7 @@ _cairo_matrix_transformed_circle_major_axis (const cairo_matrix_t *matrix, g = 0.5 * (i - j); h = a*c + b*d; - return radius * sqrt (f + sqrt (g*g+h*h)); + return radius * sqrt (f + hypot (g, h)); /* * we don't need the minor axis length, which is -- cgit v1.2.3