diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2009-08-03 22:27:22 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2009-08-06 10:15:51 +0100 |
commit | 85b688a3f6271427befca699de3a7a15162fc59e (patch) | |
tree | 15a0df2620e59e55a4bf4d1639a15d831ac4d0ac | |
parent | 0db9e010fa70c65451d324cc9c0ade989f77fedd (diff) |
[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.
-rw-r--r-- | src/cairo-matrix.c | 4 |
1 files changed, 2 insertions, 2 deletions
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 |